From 3b085286b4b06c1c7790dcd10a26640ff15b6b2b Mon Sep 17 00:00:00 2001 From: Raul Fraile Date: Fri, 4 Oct 2013 01:04:12 +0200 Subject: [PATCH] Added tests and removed unused code --- src/Ladybug/Model/VariableWrapper.php | 27 ---- src/Ladybug/Type/AbstractType.php | 5 - src/Ladybug/Type/ArrayType.php | 18 +-- src/Ladybug/Type/ArrayType/Item.php | 28 +--- src/Ladybug/Type/ObjectType.php | 142 +----------------- src/Ladybug/Type/ObjectType/Constant.php | 22 +-- .../Type/RenderizableTypeInterface.php | 6 - src/Ladybug/Type/ResourceType.php | 39 ----- .../Tests/Model/VariableWrapperTest.php | 24 +++ 9 files changed, 35 insertions(+), 276 deletions(-) create mode 100644 tests/Ladybug/Tests/Model/VariableWrapperTest.php diff --git a/src/Ladybug/Model/VariableWrapper.php b/src/Ladybug/Model/VariableWrapper.php index 54e1b56..a528ec3 100644 --- a/src/Ladybug/Model/VariableWrapper.php +++ b/src/Ladybug/Model/VariableWrapper.php @@ -41,15 +41,6 @@ public function __construct($id, $data, $type = self::TYPE_CLASS) $this->type = $type; } - /** - * Sets the variable id. - * @param string $id - */ - public function setId($id) - { - $this->id = $id; - } - /** * Gets the variable id. * @@ -60,15 +51,6 @@ public function getId() return $this->id; } - /** - * Sets the variable type - * @param int $type Variable type: TYPE_CLASS or TYPE_RESOURCE - */ - public function setType($type) - { - $this->type = $type; - } - /** * Gets the variable type. * @@ -79,15 +61,6 @@ public function getType() return $this->type; } - /** - * Sets the variable itself. - * @param mixed $data - */ - public function setData($data) - { - $this->data = $data; - } - /** * Gets variable. * diff --git a/src/Ladybug/Type/AbstractType.php b/src/Ladybug/Type/AbstractType.php index 24947a2..a033c24 100644 --- a/src/Ladybug/Type/AbstractType.php +++ b/src/Ladybug/Type/AbstractType.php @@ -211,11 +211,6 @@ public function __clone() $this->id = uniqid(); } - public function isComposed() - { - return false; - } - public function getInlineValue() { return $this->value; diff --git a/src/Ladybug/Type/ArrayType.php b/src/Ladybug/Type/ArrayType.php index 26dfa3a..6f87eb9 100644 --- a/src/Ladybug/Type/ArrayType.php +++ b/src/Ladybug/Type/ArrayType.php @@ -91,27 +91,15 @@ public function getFormattedValue() } /** - * Sets if the array is terminal - * @param boolean $terminal - */ - public function setTerminal($terminal) - { - $this->terminal = (boolean) $terminal; - } - - /** + * Checks whether the variable is terminal. + * * @return bool */ - public function getTerminal() + public function isTerminal() { return $this->terminal; } - public function isComposed() - { - return true; - } - public function getInlineValue() { $values = array(); diff --git a/src/Ladybug/Type/ArrayType/Item.php b/src/Ladybug/Type/ArrayType/Item.php index 81c5e51..16709a0 100644 --- a/src/Ladybug/Type/ArrayType/Item.php +++ b/src/Ladybug/Type/ArrayType/Item.php @@ -33,15 +33,6 @@ public function __construct($key, TypeInterface $value) $this->value = $value; } - /** - * Sets the item key - * @param string $key - */ - public function setKey($key) - { - $this->key = $key; - } - /** * Gets the item key * @@ -52,15 +43,6 @@ public function getKey() return $this->key; } - /** - * Sets the item value - * @param TypeInterface $value - */ - public function setValue($value) - { - $this->value = $value; - } - /** * Gets the item value. * @@ -71,11 +53,11 @@ public function getValue() return $this->value; } - public function setLevel($level) - { - $this->value->setLevel($level); - } - + /** + * Gets the item level. + * + * @return int + */ public function getLevel() { return $this->value->getLevel(); diff --git a/src/Ladybug/Type/ObjectType.php b/src/Ladybug/Type/ObjectType.php index f2be317..eda445f 100644 --- a/src/Ladybug/Type/ObjectType.php +++ b/src/Ladybug/Type/ObjectType.php @@ -146,11 +146,6 @@ public function load($var, $level = 1) } - public function setClassConstants($classConstants) - { - $this->classConstants = $classConstants; - } - public function getClassConstants() { return $this->classConstants; @@ -182,101 +177,51 @@ public function getMethodByName($name) return null; } - public function setClassFile($classFile) - { - $this->classFile = $classFile; - } - public function getClassFile() { return $this->classFile; } - public function setClassInterfaces($classInterfaces) - { - $this->classInterfaces = $classInterfaces; - } - public function getClassInterfaces() { return $this->classInterfaces; } - public function setClassMethods($classMethods) - { - $this->classMethods = $classMethods; - } - public function getClassMethods() { return $this->classMethods; } - public function setClassName($className) - { - $this->className = $className; - } - public function getClassName() { return $this->className; } - public function setClassNamespace($classNamespace) - { - $this->classNamespace = $classNamespace; - } - public function getClassNamespace() { return $this->classNamespace; } - public function setClassParent($classParent) - { - $this->classParent = $classParent; - } - public function getClassParent() { return $this->classParent; } - public function setClassStaticProperties($classStaticProperties) - { - $this->classStaticProperties = $classStaticProperties; - } - public function getClassStaticProperties() { return $this->classStaticProperties; } - public function setTerminal($isLeaf) - { - $this->terminal = $isLeaf; - } - - public function getTerminal() + public function isTerminal() { return $this->terminal; } - public function setObjectCustomData($objectCustomData) - { - $this->objectCustomData = $objectCustomData; - } - public function getObjectCustomData() { return $this->objectCustomData; } - public function setObjectProperties($objectProperties) - { - $this->objectProperties = $objectProperties; - } - public function getObjectProperties() { return $this->objectProperties; @@ -295,11 +240,6 @@ public function getObjectProperty($name, $visibility) return null; } - public function setToString($toString) - { - $this->toString = $toString; - } - public function getToString() { return $this->toString; @@ -494,14 +434,6 @@ protected function loadData($var, \ReflectionClass $reflectedObject) } - /** - * @param string $helpLink - */ - public function setHelpLink($helpLink) - { - $this->helpLink = $helpLink; - } - /** * @return string */ @@ -510,14 +442,6 @@ public function getHelpLink() return $this->helpLink; } - /** - * @param string $icon - */ - public function setIcon($icon) - { - $this->icon = $icon; - } - /** * @return string */ @@ -526,14 +450,6 @@ public function getIcon() return $this->icon; } - /** - * @param string $version - */ - public function setVersion($version) - { - $this->version = $version; - } - /** * @return string */ @@ -542,19 +458,6 @@ public function getVersion() return $this->version; } - public function isComposed() - { - return true; - } - - /** - * @param boolean $abstract - */ - public function setAbstract($abstract) - { - $this->abstract = $abstract; - } - /** * @return boolean */ @@ -563,14 +466,6 @@ public function isAbstract() return $this->abstract; } - /** - * @param boolean $final - */ - public function setFinal($final) - { - $this->final = $final; - } - /** * @return boolean */ @@ -579,71 +474,36 @@ public function isFinal() return $this->final; } - public function setClassTraits($classTraits) - { - $this->classTraits = $classTraits; - } - public function getClassTraits() { return $this->classTraits; } - public function setPrivatePropertiesNumber($privatePropertiesNumber) - { - $this->privatePropertiesNumber = $privatePropertiesNumber; - } - public function getPrivatePropertiesNumber() { return $this->privatePropertiesNumber; } - public function setProtectedPropertiesNumber($protectedPropertiesNumber) - { - $this->protectedPropertiesNumber = $protectedPropertiesNumber; - } - public function getProtectedPropertiesNumber() { return $this->protectedPropertiesNumber; } - public function setPublicPropertiesNumber($publicPropertiesNumber) - { - $this->publicPropertiesNumber = $publicPropertiesNumber; - } - public function getPublicPropertiesNumber() { return $this->publicPropertiesNumber; } - public function setPrivateMethodsNumber($privateMethodsNumber) - { - $this->privateMethodsNumber = $privateMethodsNumber; - } - public function getPrivateMethodsNumber() { return $this->privateMethodsNumber; } - public function setProtectedMethodsNumber($protectedMethodsNumber) - { - $this->protectedMethodsNumber = $protectedMethodsNumber; - } - public function getProtectedMethodsNumber() { return $this->protectedMethodsNumber; } - public function setPublicMethodsNumber($publicMethodsNumber) - { - $this->publicMethodsNumber = $publicMethodsNumber; - } - public function getPublicMethodsNumber() { return $this->publicMethodsNumber; diff --git a/src/Ladybug/Type/ObjectType/Constant.php b/src/Ladybug/Type/ObjectType/Constant.php index 3fcf5bf..d987f25 100644 --- a/src/Ladybug/Type/ObjectType/Constant.php +++ b/src/Ladybug/Type/ObjectType/Constant.php @@ -36,15 +36,6 @@ public function __construct($name, TypeInterface $value) $this->value = $value; } - /** - * Sets the constant name. - * @param string $name Constant name - */ - public function setName($name) - { - $this->name = $name; - } - /** * Gets the constant name. * @@ -56,16 +47,7 @@ public function getName() } /** - * Sets the constant value. - * @param TypeInterface $value Constant value - */ - public function setValue(TypeInterface $value) - { - $this->value = $value; - } - - /** - * Gets the constant value + * Gets the constant value. * * @return TypeInterface Constant value */ @@ -75,7 +57,7 @@ public function getValue() } /** - * Gets the level of the underlying object value + * Gets the level of the underlying object value. * * @return int Level */ diff --git a/src/Ladybug/Type/RenderizableTypeInterface.php b/src/Ladybug/Type/RenderizableTypeInterface.php index 49d0cc9..9fcdbe1 100644 --- a/src/Ladybug/Type/RenderizableTypeInterface.php +++ b/src/Ladybug/Type/RenderizableTypeInterface.php @@ -20,12 +20,6 @@ interface RenderizableTypeInterface extends TypeInterface */ public function getTemplateName(); - /** - * @abstract - * @return mixed - */ - public function isComposed(); - public function getInlineValue(); diff --git a/src/Ladybug/Type/ResourceType.php b/src/Ladybug/Type/ResourceType.php index b257069..f9e90f1 100644 --- a/src/Ladybug/Type/ResourceType.php +++ b/src/Ladybug/Type/ResourceType.php @@ -107,21 +107,11 @@ public function load($var, $level = 1) } - public function setResourceCustomData($resourceCustomData) - { - $this->resourceCustomData = $resourceCustomData; - } - public function getResourceCustomData() { return $this->resourceCustomData; } - public function setResourceType($resourceType) - { - $this->resourceType = $resourceType; - } - public function getResourceType() { return $this->resourceType; @@ -147,19 +137,6 @@ public function getResourceId() return $this->resourceId; } - public function isComposed() - { - return true; - } - - /** - * @param string $helpLink - */ - public function setHelpLink($helpLink) - { - $this->helpLink = $helpLink; - } - /** * @return string */ @@ -168,14 +145,6 @@ public function getHelpLink() return $this->helpLink; } - /** - * @param string $icon - */ - public function setIcon($icon) - { - $this->icon = $icon; - } - /** * @return string */ @@ -184,14 +153,6 @@ public function getIcon() return $this->icon; } - /** - * @param string $version - */ - public function setVersion($version) - { - $this->version = $version; - } - /** * @return string */ diff --git a/tests/Ladybug/Tests/Model/VariableWrapperTest.php b/tests/Ladybug/Tests/Model/VariableWrapperTest.php new file mode 100644 index 0000000..603c5e2 --- /dev/null +++ b/tests/Ladybug/Tests/Model/VariableWrapperTest.php @@ -0,0 +1,24 @@ +load(1); + + $variableWrapper = new VariableWrapper(1, $var, VariableWrapper::TYPE_CLASS); + + $this->assertInstanceOf('Ladybug\Model\VariableWrapper', $variableWrapper); + $this->assertEquals(1, $variableWrapper->getId()); + $this->assertEquals($var, $variableWrapper->getData()); + $this->assertEquals(VariableWrapper::TYPE_CLASS, $variableWrapper->getType()); + } + +}