/** * Создать Property содержащее другие Property * * @param $propertyName * @param $definitions * @return CompositeProperty * @throws PropertyFactoryExceptions */ protected static function createCompositeProperty($propertyName, $definitions) { if (!array_key_exists('properties', $definitions)) { throw PropertyFactoryExceptions::CompositePropertyMustContainsSubPropertiesDefinitions($propertyName, $definitions); } $property = new CompositeProperty($propertyName); foreach ($definitions['properties'] as $propertyName => $propertyDefinition) { $subProperty = PropertyFactory::create($propertyName, $propertyDefinition); $property->addProperty($subProperty); } return $property; }
protected function createTestGirl() { $boobsSize = new Property('boobsSize'); $greaterThenRule = new GreaterThan(); $greaterThenRule->setConfig(2); $boobsSize->addPropertyRule($greaterThenRule); $prettyFace = new Property('prettyFace'); $prettyFace->addPropertyRule(new AlwaysTrueRule()); $girl = new CompositeProperty('girl'); $girl->addProperty($boobsSize); $girl->addProperty($prettyFace); return $girl; }