/** * @param mixed $value */ protected function setValue($value) { //We use the string assertion first parent::setValue($value); //and then check, if we really got an item class Assertion::implementsInterface($value, 'Prooph\\Done\\Process\\Type\\Type'); }
/** * @test */ public function it_constructs_collection_from_json_decoded_value() { $fruits = StringCollection::fromNativeValue(array("Apple", String::fromNativeValue("Banana"), "Strawberry")); $jsonString = json_encode($fruits); $decodedJson = json_decode($jsonString); $decodedFruits = StringCollection::fromJsonDecodedData($decodedJson); $fruitList = array(); foreach ($decodedFruits->value() as $fruit) { $fruitList[] = $fruit->value(); } $this->assertEquals(array("Apple", "Banana", "Strawberry"), $fruitList); }
/** * Returns the prototype of the items type * * A collection has always one property with name item representing the type of all items in the collection. * * @return Prototype */ public static function itemPrototype() { return String::prototype(); }
/** * @return array[propertyName => Prototype] */ public static function getPropertyPrototypes() { return array('street' => String::prototype(), 'streetNumber' => Integer::prototype(), 'zip' => String::prototype(), 'city' => String::prototype()); }
/** * @test * @expectedException \Prooph\Done\Process\Type\Exception\InvalidTypeException */ public function it_only_allows_utf8_encoded_string() { $nonUtf8 = mb_convert_encoding("Ü", "ISO-8859-1", "UTF-8"); String::fromString($nonUtf8); }
/** * @return array[propertyName => Prototype] */ public static function getPropertyPrototypes() { return array('id' => Integer::prototype(), 'name' => String::prototype(), 'address' => AddressDictionary::prototype()); }