Refactor the GenericTables class #51
@ -217,31 +217,9 @@ class GenericTable
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	private function processFormatting($options, $rowData)
 | 
						private function processFormatting($options, $rowData)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (!isset($options['type']))
 | 
					 | 
				
			||||||
			$options['type'] = 'value';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Parse the basic value first.
 | 
							// Parse the basic value first.
 | 
				
			||||||
		switch ($options['type'])
 | 
							switch ($options['type'])
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			// Basic option: simply take a use a particular data property.
 | 
					 | 
				
			||||||
			case 'value':
 | 
					 | 
				
			||||||
				$value = htmlspecialchars($rowData[$options['data']] ?? '');
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Processing via a lambda function.
 | 
					 | 
				
			||||||
			case 'function':
 | 
					 | 
				
			||||||
				$value = $options['data']($rowData);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Using sprintf to fill out a particular pattern.
 | 
					 | 
				
			||||||
			case 'sprintf':
 | 
					 | 
				
			||||||
				$parameters = [$options['data']['pattern']];
 | 
					 | 
				
			||||||
				foreach ($options['data']['arguments'] as $identifier)
 | 
					 | 
				
			||||||
					$parameters[] = $rowData[$identifier];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				$value = sprintf(...$parameters);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Timestamps get custom treatment.
 | 
								// Timestamps get custom treatment.
 | 
				
			||||||
			case 'timestamp':
 | 
								case 'timestamp':
 | 
				
			||||||
				if (empty($options['data']['pattern']) || $options['data']['pattern'] === 'long')
 | 
									if (empty($options['data']['pattern']) || $options['data']['pattern'] === 'long')
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user