/** * @param array $row * @return Attribute */ private function createEntity(array $row) { $entity = new Attribute(); $entity->setId((int) $row['id']); $entity->setName($row['name']); $entity->setDescription($row['description']); $entity->setDefaultValue($row['default_value']); $entity->setIsFlag((int) $row['is_flag']); $entity->setIsHtml5((int) $row['is_html5']); $entity->setIsHtml5Support((int) $row['is_html5_support']); return $entity; }
/** * @param ClassGenerator $class * @param Attribute $tagAttribute */ protected function addAttribute(ClassGenerator $class, Attribute $tagAttribute) { $methodName = str_replace(':', '-', $tagAttribute->getName()); $methodName = ucfirst($this->stringToCamelCaseConverter->convert($methodName, '-')); $method = new MethodGenerator(); if ($tagAttribute->isFlag()) { $method->setName('is' . $methodName); $method->setParameter(new ParameterGenerator('v', 'bool', true)); } else { $method->setName('set' . $methodName); $method->setParameter(new ParameterGenerator('v', 'string')); } $body = []; $body[] = '$this->attributes[\'' . $tagAttribute->getName() . '\'] = $v;'; $body[] = 'return $this;'; $method->setBody(implode(PHP_EOL, $body)); $docBlock = new DocBlockGenerator(); $docBlock->setTag(new GenericTag('var', 'string')); $docBlock->setTag(new GenericTag('return', '$this')); if (!is_null($tagAttribute->getDescription())) { $docBlock->setLongDescription($tagAttribute->getDescription()); } $method->setDocBlock($docBlock); $class->addMethodFromGenerator($method); }