[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Configurator\Collections; 9 10 use InvalidArgumentException; 11 use ReflectionClass; 12 use s9e\TextFormatter\Configurator\JavaScript\Minifier; 13 14 class MinifierList extends NormalizedList 15 { 16 /** 17 * Normalize the value to an object 18 * 19 * @param Minifier|string $minifier 20 * @return Minifier 21 */ 22 public function normalizeValue($minifier) 23 { 24 if (is_string($minifier)) 25 { 26 $minifier = $this->getMinifierInstance($minifier); 27 } 28 elseif (is_array($minifier) && !empty($minifier[0])) 29 { 30 $minifier = $this->getMinifierInstance($minifier[0], array_slice($minifier, 1)); 31 } 32 33 if (!($minifier instanceof Minifier)) 34 { 35 throw new InvalidArgumentException('Invalid minifier ' . var_export($minifier, true)); 36 } 37 38 return $minifier; 39 } 40 41 /** 42 * Create and return a Minifier instance 43 * 44 * @param string $name Minifier's name 45 * @param array $args Constructor's arguments 46 * @return Minifier 47 */ 48 protected function getMinifierInstance($name, array $args = []) 49 { 50 $className = 's9e\\TextFormatter\\Configurator\\JavaScript\\Minifiers\\' . $name; 51 if (!class_exists($className)) 52 { 53 throw new InvalidArgumentException('Invalid minifier ' . var_export($name, true)); 54 } 55 56 $reflection = new ReflectionClass($className); 57 $minifier = (empty($args)) ? $reflection->newInstance() : $reflection->newInstanceArgs($args); 58 59 return $minifier; 60 } 61 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |