Пример #1
0
 /**
  * @param array|Traversable $array
  *
  * @throws \InvalidArgumentException
  */
 function __construct($array = null)
 {
     parent::__construct();
     if ($array === null) {
         $this->array = array();
     } else {
         if (is_array($array)) {
             $this->array = array_values($array);
         } else {
             if ($array instanceof Traversable) {
                 $this->array = iterator_to_array($array, false);
             } else {
                 throw new InvalidArgumentException('You must give an array or a Traversable');
             }
         }
     }
 }
Пример #2
0
 /**
  * @param string|string[] $string
  *
  * @throws \InvalidArgumentException
  */
 function __construct($string = null)
 {
     parent::__construct();
     if (is_array($string)) {
         $this->string = implode($string);
     } else {
         if ($string instanceof Stringer) {
             $this->string = $string->string;
         } else {
             if (is_string($string)) {
                 $this->string = $string;
             } else {
                 if ($string === null) {
                     $this->string = '';
                 } else {
                     throw new InvalidArgumentException('You must give a string or a char array');
                 }
             }
         }
     }
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 protected function resolveFunction($function)
 {
     if ($function === null) {
         return function (KeyValuePair $item) {
             return $item->getValue();
         };
     }
     return parent::resolveFunction($function);
 }