Skip to content

Commit c1c5656

Browse files
committed
Moved from spine cased to camel cased
The nodes, variables and children now use camel cased ids instead of spinal cased because it's what modern file formats use in general. Even for XML it's recommended to my surprise.
1 parent 15f7e06 commit c1c5656

27 files changed

+98
-118
lines changed

src/PE/Encoder.php

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,6 @@ protected function _decodeNode($nodeName, $nodeData, EncoderOptions $options, En
136136
$type = $proxyNode->getType($nodeType);
137137
$variableCollection = $type->getVariableCollection();
138138

139-
// make sure the variables are all dashed as this is the default
140-
foreach ($nodeDataItem as $nodeDataName => $nodeDataValue) {
141-
$nodeDataNameDashed = Inflector::underscore($nodeDataName, '-');
142-
if ($nodeDataName !== $nodeDataNameDashed) {
143-
$nodeDataItem[$nodeDataNameDashed] = $nodeDataValue;
144-
unset($nodeDataItem[$nodeDataName]);
145-
}
146-
}
147-
148139
$preNodeStaticOptions = array(
149140
NodeAccessor::VARIABLE_NODE => $type,
150141
NodeAccessor::VARIABLE_PARENT => $parentObject
@@ -188,23 +179,20 @@ protected function _decodeNode($nodeName, $nodeData, EncoderOptions $options, En
188179
$requiredVariableValues = array();
189180
foreach ($requiredVariables as $variable) {
190181

191-
// make sure the variable is underscored
192-
$processedVariable = Inflector::underscore($variable, '-');
193-
194-
if (!array_key_exists($processedVariable, $nodeDataItem)) {
195-
throw new EncoderException(sprintf('Variable "%s" for "%s" does not exist but is required to create an object for node "%s" (Node type: "%s") at index "%s"', $processedVariable, $nodeClassName, $nodeName, $type->getNodeName(), $nodeIndex));
182+
if (!array_key_exists($variable, $nodeDataItem)) {
183+
throw new EncoderException(sprintf('Variable "%s" for "%s" does not exist but is required to create an object for node "%s" (Node type: "%s") at index "%s"', $variable, $nodeClassName, $nodeName, $type->getNodeName(), $nodeIndex));
196184
}
197-
$requiredValue = $nodeDataItem[$processedVariable];
198-
$objectSetterVariable = $variableCollection->getVariableById($processedVariable);
185+
$requiredValue = $nodeDataItem[$variable];
186+
$objectSetterVariable = $variableCollection->getVariableById($variable);
199187
if (!$objectSetterVariable) {
200-
throw new EncoderException(sprintf('Variable "%s" for "%s" is required but there is no EncoderNodeVariable available to retrieve the value for node "%s" (Node type: "%s") at index "%s".', $processedVariable, $nodeClassName, $nodeName, $type->getNodeName(), $nodeIndex));
188+
throw new EncoderException(sprintf('Variable "%s" for "%s" is required but there is no EncoderNodeVariable available to retrieve the value for node "%s" (Node type: "%s") at index "%s".', $variable, $nodeClassName, $nodeName, $type->getNodeName(), $nodeIndex));
201189
}
202190

203191
$objectSetter = $objectSetterVariable->getObjectSetter();
204192
$processedRequiredValue = $objectSetter->processValue($requiredValue);
205193

206-
$requiredVariableValues[$processedVariable] = $processedRequiredValue;
207-
unset($nodeDataItem[$processedVariable]);
194+
$requiredVariableValues[$variable] = $processedRequiredValue;
195+
unset($nodeDataItem[$variable]);
208196
}
209197

210198
// create a new instance of the class

src/PE/Nodes/EncoderNodeChildren.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function addChild(EncoderNodeChild $child) {
3333
* @return null|EncoderNodeChild Returns the requested child or returns null if it's not found
3434
*/
3535
public function getChild($childName) {
36-
$childName = strtolower($childName);
3736
if ($this->childExists($childName)) {
3837
return $this->children[$childName];
3938
}
@@ -52,21 +51,19 @@ public function getChildren() {
5251
* @return bool Returns true if the child exists based on its name
5352
*/
5453
public function childExists($childName) {
55-
$nodeName = strtolower($childName);
56-
return isset($this->children[$nodeName]);
54+
return isset($this->children[$childName]);
5755
}
5856

5957
/**
6058
* Adds values to an object based on a single child
6159
*
62-
* @param string $childName Name if the child so it knows what method to use
60+
* @param string $childName Name of the child so it knows what method to use
6361
* @param object $target The target object where the values are supposed to be added to
6462
* @param array $values The values you want to add
6563
* @return bool Returns true if the action succeeded and false when it couldn't find the child
6664
*/
6765
public function addChildrenToObject($childName, $target, $values) {
68-
$child = strtolower($childName);
69-
$childNode = $this->getChild($child);
66+
$childNode = $this->getChild($childName);
7067
if (!$childNode) {
7168
throw new EncoderNodeChildException(sprintf('Trying to add children to object, but the child "%s" could not be found', $childName));
7269
}

tests/PE/Nodes/Erroneous/EncoderNodeLoaderNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class EncoderNodeLoaderNode extends EncoderNode {
99
private $overrideObjectFileName;
1010

1111
function __construct($overrideObjectFileName = true) {
12-
parent::__construct('encoder-node-loaders', 'encoder-node-loader', '\\PE\\Samples\\Erroneous');
12+
parent::__construct('encoderNodeLoaders', 'encoderNodeLoader', '\\PE\\Samples\\Erroneous');
1313

1414
$this->overrideObjectFileName = $overrideObjectFileName;
1515
}

tests/PE/Nodes/Erroneous/NoGetterMethodNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class NoGetterMethodNode extends EncoderNode {
1111

1212
function __construct() {
13-
parent::__construct('no-getter-methods', 'no-getter-method', '\\PE\\Samples\\Erroneous');
13+
parent::__construct('noGetterMethods', 'noGetterMethod', '\\PE\\Samples\\Erroneous');
1414

1515
$this->addChildNode(new EncoderNodeChild('things', new NodeChildSetter('addThing'), new NodeChildGetter('getThings')));
1616
}

tests/PE/Nodes/Erroneous/NoVariableGetterMethodNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class NoVariableGetterMethodNode extends EncoderNode {
99

1010
function __construct() {
11-
parent::__construct('no-getter-methods', 'no-getter-method', '\\PE\\Samples\\Erroneous');
11+
parent::__construct('noGetterMethods', 'noGetterMethod', '\\PE\\Samples\\Erroneous');
1212

1313
$this->addVariable(new EncoderNodeVariable('nonExistent'));
1414
}

tests/PE/Nodes/Erroneous/NonArrayGetterMethodNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class NonArrayGetterMethodNode extends EncoderNode {
1111

1212
function __construct() {
13-
parent::__construct('non-array-getter-methods', 'non-array-getter-method', '\\PE\\Samples\\Erroneous');
13+
parent::__construct('nonArrayGetterMethods', 'nonArrayGetterMethod', '\\PE\\Samples\\Erroneous');
1414

1515
$this->addChildNode(new EncoderNodeChild('things', new NodeChildSetter('addThing'), new NodeChildGetter('getThings')));
1616
}

tests/PE/Nodes/Specials/AccessorMethodActionTypeNodeNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class AccessorMethodActionTypeNodeNode extends EncoderNode {
1313

1414
function __construct() {
15-
parent::__construct('accessor-method-action-type-nodes', 'accessor-method-action-type-node', '\\PE\\Samples\\Specials');
15+
parent::__construct('accessorMethodActionTypeNodes', 'accessorMethodActionTypeNode', '\\PE\\Samples\\Specials');
1616

1717
$this->addVariable(new EncoderNodeVariable('special'));
1818

tests/PE/Nodes/Specials/AddAfterDecodeChildNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class AddAfterDecodeChildNode extends EncoderNode {
99

1010
function __construct() {
11-
parent::__construct('add-after-decode-children', 'add-after-decode-child', '\\PE\\Samples\\Specials');
11+
parent::__construct('addAfterDecodeChildren', 'addAfterDecodeChild', '\\PE\\Samples\\Specials');
1212

1313
$this->addVariable(new EncoderNodeVariable('name'));
1414
}

tests/PE/Nodes/Specials/AddAfterDecodeChildRequiresNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class AddAfterDecodeChildRequiresNode extends EncoderNode {
1414

1515
function __construct() {
16-
parent::__construct('add-after-decode-children-require', 'add-after-decode-child-require', '\\PE\\Samples\\Specials');
16+
parent::__construct('addAfterDecodeChildrenRequire', 'addAfterDecodeChildRequire', '\\PE\\Samples\\Specials');
1717

1818
$name = $this->addVariable(new EncoderNodeVariable('name'));
1919
$name->postNodeSetter(new PostNodeSetter('nodeSetName', array(NodeAccessor::VARIABLE_VALUE, NodeAccessor::VARIABLE_PARENT)));

tests/PE/Nodes/Specials/AddAfterDecodeParentNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
class AddAfterDecodeParentNode extends EncoderNode {
1212

1313
function __construct($addAfterAttributes = true) {
14-
parent::__construct('add-after-decode-parents', 'add-after-decode-parent', '\\PE\\Samples\\Specials');
14+
parent::__construct('addAfterDecodeParents', 'addAfterDecodeParent', '\\PE\\Samples\\Specials');
1515

1616
$this->addVariable(new EncoderNodeVariable('name'));
1717

1818
$addAfterDecodeChildSetter = new NodeChildSetter('addChild');
1919
$addAfterDecodeChildSetter->setAfterChildren(false);
2020
$addAfterDecodeChildSetter->setAfterAttributes($addAfterAttributes);
21-
$this->addChildNode(new EncoderNodeChild('add-after-decode-child', $addAfterDecodeChildSetter, new NodeChildGetter('getChildren')));
21+
$this->addChildNode(new EncoderNodeChild('addAfterDecodeChild', $addAfterDecodeChildSetter, new NodeChildGetter('getChildren')));
2222

23-
$this->addChildNode(new EncoderNodeChild('add-after-decode-children-require', new NodeChildSetter('addChildRequires'), new NodeChildGetter('getChildrenRequires')));
23+
$this->addChildNode(new EncoderNodeChild('addAfterDecodeChildrenRequire', new NodeChildSetter('addChildRequires'), new NodeChildGetter('getChildrenRequires')));
2424
}
2525
}

tests/PE/Nodes/Specials/ClassLoaderNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ClassLoaderNode extends EncoderNode {
1212
private $setupLoader;
1313

1414
function __construct($setupLoader) {
15-
parent::__construct('class-loaders', 'class-loader', '\\PE\\Samples\\Loader');
15+
parent::__construct('classLoaders', 'classLoader', '\\PE\\Samples\\Loader');
1616

1717
$this->setupLoader = $setupLoader;
1818
}

tests/PE/Nodes/Specials/EncoderNodeVariableApplyToSetterNode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@
1414
class EncoderNodeVariableApplyToSetterNode extends EncoderNode {
1515

1616
function __construct() {
17-
parent::__construct('encoder-node-variable-apply-to-setters-node', 'encoder-node-variable-apply-to-setters-node', '\\PE\\Samples\\Specials');
17+
parent::__construct('encoderNodeVariableApplyToSettersNode', 'encoderNodeVariableApplyToSetterNode', '\\PE\\Samples\\Specials');
1818

19-
$nodeSimple = $this->addVariable(new EncoderNodeVariable('node-simple'));
19+
$nodeSimple = $this->addVariable(new EncoderNodeVariable('nodeSimple'));
2020
$nodeSimple->postNodeSetter(new PostNodeSetter('nodeSimple', array(NodeAccessor::VARIABLE_NAME)));
2121

22-
$nodeFull = $this->addVariable(new EncoderNodeVariable('node-full'));
22+
$nodeFull = $this->addVariable(new EncoderNodeVariable('nodeFull'));
2323
$nodeFull->postNodeSetter(new PostNodeSetter('nodeFull', array(
2424
NodeAccessor::VARIABLE_NAME,
2525
NodeAccessor::VARIABLE_VALUE,
2626
NodeAccessor::VARIABLE_OBJECT,
2727
NodeAccessor::VARIABLE_PARENT
2828
)));
2929

30-
$nodeWithoutVariables = $this->addVariable(new EncoderNodeVariable('node-without-variables'));
30+
$nodeWithoutVariables = $this->addVariable(new EncoderNodeVariable('nodeWithoutVariables'));
3131
$nodeWithoutVariables->postNodeSetter(new PostNodeSetter('nodeWithoutVariables'));
3232

33-
$nodeWithoutVariablesEmpty = $this->addVariable(new EncoderNodeVariable('node-without-variables-empty'));
33+
$nodeWithoutVariablesEmpty = $this->addVariable(new EncoderNodeVariable('nodeWithoutVariablesEmpty'));
3434
$nodeWithoutVariablesEmpty->postNodeSetter(new PostNodeSetter('nodeWithoutVariables', array()));
3535

36-
$nodeWithoutVariablesNull = $this->addVariable(new EncoderNodeVariable('node-without-variables-null'));
36+
$nodeWithoutVariablesNull = $this->addVariable(new EncoderNodeVariable('nodeWithoutVariablesNull'));
3737
$nodeWithoutVariablesNull->postNodeSetter(new PostNodeSetter('nodeWithoutVariables', array()));
3838

39-
$nodeUnknownVariable = $this->addVariable(new EncoderNodeVariable('node-unknown-variable'));
39+
$nodeUnknownVariable = $this->addVariable(new EncoderNodeVariable('nodeUnknownVariable'));
4040
$nodeUnknownVariable->postNodeSetter(new PostNodeSetter('nodeSimple', array('unknown_variable')));
4141

4242
$this->addVariable(new EncoderNodeVariable('var'));

tests/PE/Nodes/Specials/HasDefaultTypeNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class HasDefaultTypeNode extends EncoderNode {
1010
const NEW_DEFAULT_TYPE = 'should-be-the-default-type';
1111

1212
function __construct($nodeTypeName = null) {
13-
parent::__construct('has-default-types', 'has-default-type', '\\PE\\Samples\\Specials', $nodeTypeName);
13+
parent::__construct('hasDefaultTypes', 'hasDefaultType', '\\PE\\Samples\\Specials', $nodeTypeName);
1414
}
1515

1616
public function getDefaultType() {

tests/PE/Nodes/Specials/NonArrayGetterMethodOnPurposeNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class NonArrayGetterMethodOnPurposeNode extends EncoderNode {
1111

1212
function __construct() {
13-
parent::__construct('non-array-getter-methods-on-purpose', 'non-array-getter-method-on-purpose', '\\PE\\Samples\\Specials');
13+
parent::__construct('nonArrayGetterMethodsOnPurpose', 'nonArrayGetterMethodOnPurpose', '\\PE\\Samples\\Specials');
1414

1515
$things = $this->addChildNode(new EncoderNodeChild('things', new NodeChildSetter('addThing'), new NodeChildGetter('getThing')));
1616
$things->isArray(false);

tests/PE/Nodes/Specials/OptionalVariablesNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
class OptionalVariablesNode extends EncoderNode {
99

1010
function __construct() {
11-
parent::__construct('optional-variables', 'optional-variables', '\\PE\\Samples\\Specials');
11+
parent::__construct('optionalVariables', 'optionalVariables', '\\PE\\Samples\\Specials');
1212

1313
$this->addVariable(new EncoderNodeVariable('name'));
14-
$this->addVariable(new EncoderNodeVariable('other-variable'));
14+
$this->addVariable(new EncoderNodeVariable('otherVariable'));
1515
}
1616
}

tests/PE/Nodes/Specials/RequiredConstructorVariablesNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
class RequiredConstructorVariablesNode extends EncoderNode {
99

1010
function __construct($addVariables = true) {
11-
parent::__construct('required-constructors-variables', 'required-constructor-variables', '\\PE\\Samples\\Specials');
11+
parent::__construct('requiredConstructorsVariables', 'requiredConstructorVariables', '\\PE\\Samples\\Specials');
1212

1313
if ($addVariables === true) {
1414
$this->addVariable(new EncoderNodeVariable('name'));
15-
$this->addVariable(new EncoderNodeVariable('variable-category'));
15+
$this->addVariable(new EncoderNodeVariable('variableCategory'));
1616
}
1717
}
1818
}

tests/PE/Nodes/Specials/RequiredVariableNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class RequiredVariableNode extends EncoderNode {
99

1010
function __construct() {
11-
parent::__construct('required-variables', 'required-variable', '\\PE\\Samples\\Specials');
11+
parent::__construct('requiredVariables', 'requiredVariable', '\\PE\\Samples\\Specials');
1212

1313
$thing = $this->addVariable(new EncoderNodeVariable('required'));
1414
$thing->getObjectSetter()->required(true);

tests/PE/Nodes/Specials/SingleChildNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class SingleChildNode extends EncoderNode {
1111

1212
function __construct() {
13-
parent::__construct('single-children', 'single-child', '\\PE\\Samples\\Specials');
13+
parent::__construct('singleChildren', 'singleChild', '\\PE\\Samples\\Specials');
1414

1515
$thing = $this->addChildNode(new EncoderNodeChild('thing', new NodeChildSetter('setThing'), new NodeChildGetter('getThing')));
1616
$thing->isArray(false);

tests/PE/Nodes/Specials/VariableTypesNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class VariableTypesNode extends EncoderNode {
1515

1616
function __construct() {
17-
parent::__construct('variable-types', 'variable-type', '\\PE\\Samples\\Specials');
17+
parent::__construct('variableTypes', 'variableType', '\\PE\\Samples\\Specials');
1818

1919
$required = $this->addVariable(new EncoderNodeVariable('required'));
2020
$required->setType(EncoderNodeVariable::TYPE_STRING);

0 commit comments

Comments
 (0)