/** * @param mixed $value * * @return $this */ public function add($value) { if (!$value instanceof FileNodeInterface) { throw new InvalidArgumentException("The specified value does not implement FileNodeInterface"); } return parent::add($value); }
/** * @inheritdoc */ public function flow(NodeInterface $node) { $collection = new NodeCollection(); foreach ($this->items as $flow) { $collection->add($flow->flow($node)); } return $collection; }
public function testBuildingAFlowWhenALoggerIsSetWillSetTheLoggerOnTheChild() { $logger = m::mock(LoggerInterface::class); $this->builder->setLogger($logger); $logger->shouldReceive('log')->times(2); $flow = $this->builder->buildFlow('first'); $collection = new NodeCollection(); $node = m::mock(NodeInterface::class); $collection->add($node); $first = $flow->flow($collection); static::assertEquals($node, $first); }
public function testCallingApplyWillModifyTheContentsUsingReturnValue() { $node = m::mock(NodeInterface::class); $node->shouldReceive('someMethod')->once()->andReturn(null); $collection = new NodeCollection(); $collection->add($node); $collection->apply(function ($item) { $item->someMethod(); return $item; }); $item = $collection->getAll()[0]; static::assertSame($node, $item); }