[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/JavaScript/Minifiers/ -> FirstAvailable.php (source)

   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\JavaScript\Minifiers;
   9  
  10  use ArrayAccess;
  11  use Exception;
  12  use RuntimeException;
  13  use s9e\TextFormatter\Configurator\Collections\MinifierList;
  14  use s9e\TextFormatter\Configurator\JavaScript\Minifier;
  15  use s9e\TextFormatter\Configurator\Traits\CollectionProxy;
  16  
  17  
  18  /**
  19  * @method mixed    add(mixed $value, null $void)  Add (append) a value to this list
  20  * @method mixed    append(mixed $value)           Append a value to this list
  21  * @method array    asConfig()
  22  * @method void     clear()                        Empty this collection
  23  * @method bool     contains(mixed $value)         Test whether a given value is present in this collection
  24  * @method integer  count()
  25  * @method mixed    current()
  26  * @method void     delete(string $key)            Delete a value from this list and remove gaps in keys
  27  * @method bool     exists(string $key)            Test whether an item of given key exists
  28  * @method mixed    get(string $key)               Return a value from this collection
  29  * @method mixed    indexOf(mixed $value)          Find the index of a given value
  30  * @method mixed    insert(integer $offset, mixed $value) Insert a value at an arbitrary 0-based position
  31  * @method integer|string key()
  32  * @method mixed    next()
  33  * @method integer  normalizeKey(mixed $key)       Ensure that the key is a valid offset
  34  * @method Minifier normalizeValue(Minifier|string $minifier) Normalize the value to an object
  35  * @method bool     offsetExists(string|integer $offset)
  36  * @method mixed    offsetGet(string|integer $offset)
  37  * @method void     offsetSet(mixed $offset, mixed $value) Custom offsetSet() implementation to allow assignment with a null offset to append to the
  38  * @method void     offsetUnset(string|integer $offset)
  39  * @method string   onDuplicate(string|null $action) Query and set the action to take when add() is called with a key that already exists
  40  * @method mixed    prepend(mixed $value)          Prepend a value to this list
  41  * @method integer  remove(mixed $value)           Remove all items matching given value
  42  * @method void     rewind()
  43  * @method mixed    set(string $key, mixed $value) Set and overwrite a value in this collection
  44  * @method bool     valid()
  45  */
  46  class FirstAvailable extends Minifier implements ArrayAccess
  47  {
  48      use CollectionProxy;
  49  
  50      /**
  51      * @var MinifierList
  52      */
  53      protected $collection;
  54  
  55      /**
  56      * Constructor
  57      */
  58  	public function __construct()
  59      {
  60          $this->collection = new MinifierList;
  61          foreach (func_get_args() as $minifier)
  62          {
  63              $this->collection->add($minifier);
  64          }
  65      }
  66  
  67      /**
  68      * {@inheritdoc}
  69      */
  70  	public function minify($src)
  71      {
  72          foreach ($this->collection as $minifier)
  73          {
  74              try
  75              {
  76                  return $minifier->minify($src);
  77              }
  78              catch (Exception $e)
  79              {
  80                  // Do nothing
  81              }
  82          }
  83  
  84          throw new RuntimeException('No minifier available');
  85      }
  86  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1