Exemplo n.º 1
0
 /**
  * @param mixed               $item
  * @param CollectionInterface $collection
  *
  * @return bool
  */
 public function __invoke($item, CollectionInterface $collection)
 {
     if (self::VALIDATE_KEY === $this->mode) {
         return !$collection->has($item);
     }
     return !$collection->contains($item, $this->strict);
 }
Exemplo n.º 2
0
 /**
  * @param CollectionInterface $from
  * @param CollectionInterface $to
  *
  * @return Collection
  */
 private function getNew(CollectionInterface $from, CollectionInterface $to)
 {
     $added = [];
     foreach ($to as $name => $element) {
         if (!$from->has($name)) {
             $added[$name] = $element;
         }
     }
     return new Collection($added);
 }
Exemplo n.º 3
0
 /**
  * @return mixed
  */
 public function execute()
 {
     if ($this->collection instanceof PipelineInterface) {
         $collection = $this->collection->execute();
         if (!$collection instanceof CollectionInterface) {
             throw new \UnexpectedValueException('Expecting an instance of ' . CollectionInterface::class);
         }
     } else {
         $collection = $this->collection;
     }
     return call_user_func($this->callback, $collection);
 }
Exemplo n.º 4
0
 /**
  * @param string $name
  *
  * @return CollectionInterface
  */
 public function additional($name = null)
 {
     return isset($name) ? $this->newElements->get($name) : $this->newElements;
 }
Exemplo n.º 5
0
 /**
  * @param integer             $index
  * @param CollectionInterface $collection
  *
  * @return bool
  */
 public function __invoke($index, CollectionInterface $collection)
 {
     return is_numeric($index) && $index <= $collection->count();
 }