Exemplo n.º 1
0
 /**
  * Initializes a new instance of that class.
  *
  * @param callable $provider The callable that provides the value.
  *
  * @throws ArgumentException $provider is no valid callable / lambda expression.
  * @throws ArgumentNullException $provider is (null).
  */
 public function __construct($provider)
 {
     if (null === $provider) {
         throw new ArgumentNullException('provider');
     }
     parent::__construct(static::asCallable($provider));
 }
Exemplo n.º 2
0
 /**
  * Initializes a new instance of that class.
  *
  * @param mixed $value The value to wrap.
  * @param callable $converter The converter to use.
  */
 public function __construct($value, $converter = null)
 {
     $this->_converter = static::getConverterSafe($converter);
     parent::__construct($value);
 }
Exemplo n.º 3
0
 /**
  * Initializes a new instance of that class.
  *
  * @param mixed $value The value to wrap.
  * @param callable $equalityComparer The custom equality comparer to use.
  *
  * @throws ArgumentException $equalityComparer is no valid callable / lambda expression.
  */
 public function __construct($value, $equalityComparer = null)
 {
     $this->_equalityComparer = static::getEqualityComparerSafe($equalityComparer);
     parent::__construct($value);
 }
Exemplo n.º 4
0
 public function map($callback)
 {
     $data =& $this->getValue();
     if ($data != null && is_array($data)) {
         $toMap =& $data;
     } else {
         $toMap = array($data);
     }
     $mapped = new ValueWrapper(array());
     foreach ($toMap as $key => $value) {
         $mappedVal = $callback($key, $value, new DataWrapper($this, $key), new ValueWrapperRef($value));
         static::unwrapValue($mappedVal);
         $mapped->set($key, $mappedVal);
     }
     return $mapped;
 }