/** * Class constructor. * @param \Brickoo\Component\Common\Collection $definitionsCollection * @throws InvalidTypeException */ public function __construct(Collection $definitionsCollection) { if ($definitionsCollection->getType() !== "Brickoo\\Component\\Annotation\\Definition\\AnnotationDefinition") { throw new InvalidTypeException($definitionsCollection->getType()); } $this->definitionsCollection = $definitionsCollection; }
/** * @covers Brickoo\Component\Common\Collection::__construct * @covers Brickoo\Component\Common\Collection::fromArray * @covers Brickoo\Component\Common\Collection::add * @covers Brickoo\Component\Common\Collection::checkItemType * @covers Brickoo\Component\Common\Collection::isEmpty * @covers Brickoo\Component\Common\Collection::getType * @covers Brickoo\Component\Common\Collection::getItemType * @covers Brickoo\Component\Common\Exception\InvalidTypeException * @expectedException \Brickoo\Component\Common\Exception\InvalidTypeException */ public function testCollectionCanOnlyContainOneTypeOfValues() { $collection = new Collection(["a", "b", "c"]); $this->assertEquals("string", $collection->getType()); $collection = new Collection([new \stdClass()]); $this->assertEquals("stdClass", $collection->getType()); new Collection(["a", 1, 2]); }