コード例 #1
0
ファイル: UtilTest.php プロジェクト: gingerwfms/ginger-core
 /**
  * @covers Ginger\Core\Util\Util::getType
  */
 public function testGetType()
 {
     $this->assertEquals('null', Util::getType(NULL));
     $this->assertEquals('string', Util::getType('a string'));
     $this->assertEquals('stdClass', Util::getType(new \stdClass()));
     $this->assertEquals('GingerCoreTest\\Util\\UtilTest', Util::getType($this));
 }
コード例 #2
0
 public static function fromEventDescriptionDefinitions(array $anEventDescriptionDefinitionCollection)
 {
     $eventDescriptions = array();
     foreach ($anEventDescriptionDefinitionCollection as $eventName => $structurePathValueTypeList) {
         Assertion::string($eventName, sprintf("EventName must be a string: %s given in EventDescriptionDefinitionCollection: %s", Util::getType($eventName), json_encode($anEventDescriptionDefinitionCollection)));
         $eventDescriptions[$eventName] = EventDescription::fromNameAndStructurePathValueTypeList($eventName, $structurePathValueTypeList);
     }
     return new static($eventDescriptions);
 }
コード例 #3
0
ファイル: ResourceId.php プロジェクト: gingerwfms/ginger-core
 /**
  * Construct with the string representation of the ResourceId
  * 
  * @param string $resourceId
  */
 public function __construct($resourceId)
 {
     if (!is_string($resourceId)) {
         throw new InvalidArgumentException(sprintf('ResourceId must be of type string, <%s> given', Util::getType($resourceId)));
     }
     if (empty($resourceId)) {
         throw new InvalidArgumentException('ResourceId must not be empty');
     }
     $this->value = (string) $resourceId;
 }
コード例 #4
0
ファイル: EventName.php プロジェクト: gingerwfms/ginger-core
 public function __construct($aName)
 {
     Assertion::string($aName, sprintf("An EventName must be a string %s given", Util::getType($aName)));
     Assertion::minLength($aName, 5, sprintf("An EventName must be at least 5 chars long, less given in: %s", $aName));
     $this->name = $aName;
 }
コード例 #5
0
 /**
  * @param array $anActionDescriptionDefinition
  * @return ActionDescription
  */
 public static function actionDescriptionFromDefinition(array $anActionDescriptionDefinition)
 {
     Assertion::keyExists($anActionDescriptionDefinition, 'name', sprintf("Missing name property in ActionDescriptionDefinition: %s", json_encode($anActionDescriptionDefinition)));
     Assertion::keyExists($anActionDescriptionDefinition, 'type', sprintf("Missing type property in ActionDescriptionDefinition: %s", json_encode($anActionDescriptionDefinition)));
     if ($anActionDescriptionDefinition['type'] === Type::COMMAND) {
         Assertion::keyExists($anActionDescriptionDefinition, 'events', sprintf("Missing events property in ActionDescriptionDefinition: %s", json_encode($anActionDescriptionDefinition)));
         $eventsDefinition = EventsDefinition::fromEventDescriptionDefinitions($anActionDescriptionDefinition['events']);
     } else {
         $eventsDefinition = null;
     }
     if (isset($anActionDescriptionDefinition['arguments'])) {
         Assertion::isArray($anActionDescriptionDefinition['arguments'], sprintf("The arguments property of ActionDescriptionDefinition must be an array: %s given in %s", Util::getType($anActionDescriptionDefinition['arguments']), json_encode($anActionDescriptionDefinition)));
         $arguments = new Arguments($anActionDescriptionDefinition['arguments']);
     } else {
         $arguments = new Arguments(array());
     }
     if (isset($anActionDescriptionDefinition['structure'])) {
         Assertion::isArray($anActionDescriptionDefinition['structure'], sprintf("The structure property of ActionDescriptionDefinition must be an array: %s given in %s", Util::getType($anActionDescriptionDefinition['structure']), json_encode($anActionDescriptionDefinition)));
         $structureDefinition = StructureDefinition::fromPathValueTypeList($anActionDescriptionDefinition['structure']);
     } else {
         $structureDefinition = null;
     }
     if ($anActionDescriptionDefinition['type'] === Type::COMMAND) {
         return ActionDescription::asCommand(new Name($anActionDescriptionDefinition['name']), $eventsDefinition, $arguments, $structureDefinition);
     } else {
         return ActionDescription::asQuery(new Name($anActionDescriptionDefinition['name']), $arguments, $structureDefinition);
     }
 }