Skip to content

Commit

Permalink
feat: fix bugs in collections and improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vicvolk committed Sep 15, 2021
1 parent 1292545 commit 8280a78
Show file tree
Hide file tree
Showing 30 changed files with 775 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":1,"defects":{"Warning":6,"Tests\\Unit\\ModelTest::testGetTypes":4,"Tests\\Unit\\ModelTest::testGetType":5,"Tests\\Unit\\ModelTest::testGetTypeForName":5,"Tests\\Unit\\ModelTest::testEqual":5,"Tests\\Xml\\Type\\ModelElementTypeTest::testTypeName":3,"Tests\\Xml\\Type\\ModelElementTypeTest::testAttributes":3,"Tests\\Xml\\Type\\ModelElementTypeTest::testBaseType":4,"Tests\\Xml\\Type\\ModelElementTypeTest::testAbstractType":4,"Tests\\Xml\\Type\\ModelElementTypeTest::testModel":5,"Tests\\Xml\\Type\\ModelElementTypeTest::testInstances":5,"Tests\\Xml\\Type\\ModelElementTypeTest::testChildElementTypes":4,"Tests\\Xml\\AnimalTest::testSetIdAttributeByHelper with data set #0":4,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testRemoveIdAttribute":4,"Tests\\Xml\\AnimalCreateTest::testRemoveNameAttribute":4,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeNameWithNamespace":4,"Tests\\Xml\\AnimalCreateTest::testRemoveFatherAttribute":4,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfFatherReference":4,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testReplaceFatherReferenceWithNewAnimal":4,"Tests\\Xml\\AnimalCreateTest::testRemoveMotherAttribute":4,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfMotherReference":5,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testReplaceMotherReferenceWithNewAnimal":4},"times":{"Tests\\Unit\\StringUtilTest::testStringListSplit":0.0030000000000000001,"Tests\\Unit\\StringUtilTest::testStringListJoin":0,"Warning":0,"Tests\\Unit\\ModelTest::testGetTypes":0.025999999999999999,"Tests\\Unit\\ModelTest::testGetType":0.001,"Tests\\Unit\\ModelTest::testGetTypeForName":0.024,"Tests\\Unit\\ModelTest::testGetModelName":0.021000000000000001,"Tests\\Unit\\ModelTest::testEqual":0.42099999999999999,"Tests\\Xml\\Type\\ModelElementTypeTest::testTypeName":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testTypeNamespace":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testInstanceType":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testAttributes":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testBaseType":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testAbstractType":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testModel":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testInstances":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testChildElementTypes":0,"Tests\\Xml\\AnimalTest::testSetIdAttributeByHelper with data set #0":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByHelper":0.021000000000000001,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByAttributeName":0.001,"Tests\\Xml\\AnimalCreateTest::testRemoveIdAttribute":0.001,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByHelper":0.001,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByAttributeName":0.001,"Tests\\Xml\\AnimalCreateTest::testRemoveNameAttribute":0.001,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByHelper":0.001,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeName":0.001,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeNameWithNamespace":0.001,"Tests\\Xml\\AnimalCreateTest::testRemoveFatherAttribute":0.001,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfFatherReference":0.001,"Tests\\Xml\\ModelTest::testGetTypes":0,"Tests\\Xml\\ModelTest::testGetType":0,"Tests\\Xml\\ModelTest::testGetTypeForName":0,"Tests\\Xml\\ModelTest::testGetModelName":0,"Tests\\Xml\\StringUtilTest::testStringListSplit":0,"Tests\\Xml\\StringUtilTest::testStringListJoin":0,"Tests\\Xml\\AnimalCreateTest::testReplaceFatherReferenceWithNewAnimal":0.001,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByHelper":0.001,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByAttributeName":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testRemoveMotherAttribute":0.001,"Tests\\Xml\\AnimalCreateTest::testReplaceMotherReferenceWithNewAnimal":0.001,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfMotherReference":0.001}}
{"version":1,"defects":{"Warning":6,"Tests\\Unit\\ModelTest::testGetTypes":4,"Tests\\Unit\\ModelTest::testGetType":5,"Tests\\Unit\\ModelTest::testGetTypeForName":5,"Tests\\Unit\\ModelTest::testEqual":5,"Tests\\Xml\\Type\\ModelElementTypeTest::testTypeName":3,"Tests\\Xml\\Type\\ModelElementTypeTest::testAttributes":3,"Tests\\Xml\\Type\\ModelElementTypeTest::testBaseType":4,"Tests\\Xml\\Type\\ModelElementTypeTest::testAbstractType":4,"Tests\\Xml\\Type\\ModelElementTypeTest::testModel":5,"Tests\\Xml\\Type\\ModelElementTypeTest::testInstances":5,"Tests\\Xml\\Type\\ModelElementTypeTest::testChildElementTypes":4,"Tests\\Xml\\AnimalTest::testSetIdAttributeByHelper with data set #0":4,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testRemoveIdAttribute":4,"Tests\\Xml\\AnimalCreateTest::testRemoveNameAttribute":4,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeNameWithNamespace":4,"Tests\\Xml\\AnimalCreateTest::testRemoveFatherAttribute":4,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfFatherReference":4,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testReplaceFatherReferenceWithNewAnimal":4,"Tests\\Xml\\AnimalCreateTest::testRemoveMotherAttribute":4,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfMotherReference":4,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testReplaceMotherReferenceWithNewAnimal":4,"Tests\\Xml\\AnimalCreateTest::testGetELementById":4,"Tests\\Xml\\AnimalCreateTest::testSetIsEndangeredAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testRemoveIsEndangeredAttribute":4,"Tests\\Xml\\AnimalCreateTest::testSetGenderAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetGenderAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testRemoveGenderAttribute":4,"Tests\\Xml\\AnimalCreateTest::testRemoveAgeAttribute":4,"Tests\\Xml\\AnimalCreateTest::testAddRelationshipDefinitionsByHelper":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByReplaceElements":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByIdByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testAddRelationsDefinitionRefsByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetIsEndangeredAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetAgeAttributeByHelper":4,"Tests\\Xml\\AnimalCreateTest::testSetAgeAttributeByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByIdByHelper":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByIdByAttributeName":4,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitions":4,"Tests\\Xml\\AnimalCreateTest::testGetElementById":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByRemoveElements":4,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionsRefs":4,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefsByClearRelationshipDefinitions":4,"Tests\\Xml\\AnimalCreateTest::testAddRelationshipDefinitionRefElementsByHelper":4,"Tests\\Xml\\AnimalCreateTest::testRelationshipDefinitionRefElementsByTextContent":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefElementsByTextContent":4,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefElementsByClearRelationshipDefinitionRefs":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByIdByHelper":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByReplaceElements":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByRemoveIdAttribute":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefElementsByTextContentWithNamespace":4,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefElementsByRemoveElements":4,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefElements":4,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefElementsByClearRelationshipDefinitions":4,"Tests\\Xml\\AnimalCreateTest::testGetBestFriends":4,"Tests\\Xml\\AnimalCreateTest::testRemoveBestFriendRef":3,"Tests\\Xml\\AnimalCreateTest::testClearBestFriendRef":4},"times":{"Tests\\Unit\\StringUtilTest::testStringListSplit":0.0030000000000000001,"Tests\\Unit\\StringUtilTest::testStringListJoin":0,"Warning":0,"Tests\\Unit\\ModelTest::testGetTypes":0.025999999999999999,"Tests\\Unit\\ModelTest::testGetType":0.001,"Tests\\Unit\\ModelTest::testGetTypeForName":0.024,"Tests\\Unit\\ModelTest::testGetModelName":0.021000000000000001,"Tests\\Unit\\ModelTest::testEqual":0.42099999999999999,"Tests\\Xml\\Type\\ModelElementTypeTest::testTypeName":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testTypeNamespace":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testInstanceType":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testAttributes":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testBaseType":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testAbstractType":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testModel":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testInstances":0,"Tests\\Xml\\Type\\ModelElementTypeTest::testChildElementTypes":0,"Tests\\Xml\\AnimalTest::testSetIdAttributeByHelper with data set #0":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByHelper":0.002,"Tests\\Xml\\AnimalCreateTest::testSetIdAttributeByAttributeName":0.001,"Tests\\Xml\\AnimalCreateTest::testRemoveIdAttribute":0.001,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByHelper":0.001,"Tests\\Xml\\AnimalCreateTest::testSetNameAttributeByAttributeName":0.01,"Tests\\Xml\\AnimalCreateTest::testRemoveNameAttribute":0.002,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByHelper":0.002,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeName":0.002,"Tests\\Xml\\AnimalCreateTest::testSetFatherAttributeByAttributeNameWithNamespace":0.002,"Tests\\Xml\\AnimalCreateTest::testRemoveFatherAttribute":0.0080000000000000002,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfFatherReference":0.002,"Tests\\Xml\\ModelTest::testGetTypes":0,"Tests\\Xml\\ModelTest::testGetType":0,"Tests\\Xml\\ModelTest::testGetTypeForName":0,"Tests\\Xml\\ModelTest::testGetModelName":0,"Tests\\Xml\\StringUtilTest::testStringListSplit":0,"Tests\\Xml\\StringUtilTest::testStringListJoin":0,"Tests\\Xml\\AnimalCreateTest::testReplaceFatherReferenceWithNewAnimal":0.002,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByHelper":0.002,"Tests\\Xml\\AnimalCreateTest::testSetMotherAttributeByAttributeName":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testRemoveMotherAttribute":0.002,"Tests\\Xml\\AnimalCreateTest::testReplaceMotherReferenceWithNewAnimal":0.002,"Tests\\Xml\\AnimalCreateTest::testChangeIdAttributeOfMotherReference":0.002,"Tests\\Xml\\AnimalCreateTest::testGetELementByDefaultId":0.23200000000000001,"Tests\\Xml\\AnimalCreateTest::testGetELementById":0.014999999999999999,"Tests\\Xml\\AnimalCreateTest::testSetIsEndangeredAttributeByHelper":0.002,"Tests\\Xml\\AnimalCreateTest::testSetIsEndangeredAttributeByAttributeName":0.002,"Tests\\Xml\\AnimalCreateTest::testRemoveIsEndangeredAttribute":0.002,"Tests\\Xml\\AnimalCreateTest::testSetGenderAttributeByHelper":0.002,"Tests\\Xml\\AnimalCreateTest::testSetGenderAttributeByAttributeName":0.002,"Tests\\Xml\\AnimalCreateTest::testRemoveGenderAttribute":0.0040000000000000001,"Tests\\Xml\\AnimalCreateTest::testSetAgeAttributeByHelper":0.002,"Tests\\Xml\\AnimalCreateTest::testSetAgeAttributeByAttributeName":0.001,"Tests\\Xml\\AnimalCreateTest::testRemoveAgeAttribute":0.002,"Tests\\Xml\\AnimalCreateTest::testAddRelationshipDefinitionsByHelper":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByIdByHelper":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByReplaceElements":0.002,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByRemoveElements":0.001,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitions":0.01,"Tests\\Xml\\AnimalCreateTest::testAddRelationsDefinitionRefsByHelper":0.0030000000000000001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByIdByHelper":0.001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByIdByAttributeName":0.001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionsByIdByAttributeName":0.002,"Tests\\Xml\\AnimalCreateTest::testGetElementById":0.014999999999999999,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByReplaceElements":0.001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByRemoveElements":0.001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefsByRemoveIdAttribute":0.001,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionsRefs":0.001,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefsByClearRelationshipDefinitions":0.001,"Tests\\Xml\\AnimalCreateTest::testAddRelationshipDefinitionRefElementsByHelper":0.0040000000000000001,"Tests\\Xml\\AnimalCreateTest::testRelationshipDefinitionRefElementsByTextContent":0.001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefElementsByTextContent":0.002,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefElementsByTextContentWithNamespace":0.001,"Tests\\Xml\\AnimalCreateTest::testUpdateRelationshipDefinitionRefElementsByRemoveElements":0.001,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefElements":0.001,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefElementsByClearRelationshipDefinitionRefs":0.001,"Tests\\Xml\\AnimalCreateTest::testClearRelationshipDefinitionRefElementsByClearRelationshipDefinitions":0.002,"Tests\\Xml\\AnimalCreateTest::testGetBestFriends":0.001,"Tests\\Xml\\AnimalCreateTest::testAddBestFriend":0.001,"Tests\\Xml\\AnimalCreateTest::testRemoveBestFriendRef":0.001,"Tests\\Xml\\AnimalCreateTest::testClearBestFriendRef":0.001,"Tests\\Xml\\AnimalCreateTest::testClearAndAddBestFriendRef":0.001}}
13 changes: 6 additions & 7 deletions src/Model/Xml/Impl/Instance/DomElementImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public function replaceChild(
): void {
$newElement = $newChildDomElement->getElement();
$existingElement = $existingChildDomElement->getElement();
if ($this->element->replaceChild($newElement, $existingElement) === false) {
throw new \DOMException("Unable to replace child element with new element");
}
}

public function removeChild(DomElementInterface $childDomElement): bool
Expand Down Expand Up @@ -178,12 +181,12 @@ public function setAttribute(?string $namespaceUri, string $localName, string $v
$xmlQName = new XmlQName($this->getDocument(), $this, $namespaceUri, $localName);
if ($xmlQName->hasLocalNamespace()) {
$this->element->setAttribute($xmlQName->getLocalName(), $value);
if ($isIdAttribute) {
if ($isIdAttribute && !$this->element->getAttributeNode("id")->isId()) {
$this->element->setIdAttribute($xmlQName->getLocalName(), true);
}
} else {
$this->element->setAttributeNS($xmlQName->getNamespaceUri(), $xmlQName->getPrefixedName(), $value);
if ($isIdAttribute) {
if ($isIdAttribute && !$this->element->getAttributeNodeNS($xmlQName->getNamespaceUri(), "id")->isId()) {
$this->element->setIdAttributeNS($xmlQName->getNamespaceUri(), $xmlQName->getLocalName(), true);
}
}
Expand Down Expand Up @@ -275,14 +278,10 @@ public function lookupPrefix(string $namespaceUri): string

public function equals(?DomElementInterface $obj): bool
{
if ($this == $obj) {
return true;
}

if ($obj == null) {
return false;
}

return $this->element == $obj->element;
return $this->element->isSameNode($obj->getElement());
}
}
23 changes: 13 additions & 10 deletions src/Model/Xml/Impl/ModelInstanceImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,23 @@ public function setDocumentElement(ModelElementInstanceInterface $modelElement):
*/
public function newInstance($type, ?string $id = null): ModelElementInstanceInterface
{
$modelElementType = $this->model->getType($type);
if ($modelElementType != null) {
$modelElementInstance = $modelElementType->newInstance($this, null);
if (!empty($id)) {
ModelUtil::setNewIdentifier($modelElementType, $modelElementInstance, $id, false);
if (is_string($type)) {
$modelElementType = $this->model->getType($type);
if ($modelElementType != null) {
$type = $modelElementType;
} else {
ModelUtil::setGeneratedUniqueIdentifier($modelElementType, $modelElementInstance, false);
throw new ModelException(
sprintf("Cannot create instance of ModelType %s: no such type registered.", $type)
);
}
return $modelElementInstance;
}
$modelElementInstance = $type->newInstance($this);
if (!empty($id)) {
ModelUtil::setNewIdentifier($type, $modelElementInstance, $id, false);
} else {
throw new ModelException(
sprintf("Cannot create instance of ModelType %s: no such type registered.", $type)
);
ModelUtil::setGeneratedUniqueIdentifier($type, $modelElementInstance, false);
}
return $modelElementInstance;
}

public function getModel(): ModelInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Xml/Impl/Type/Attribute/AttributeImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getValue(ModelElementInstanceInterface $modelElement)
}
}

if ($value == null && $this->defaultValue != null) {
if ($value === null && $this->defaultValue !== null) {
return $this->defaultValue;
} else {
return $this->convertXmlValueToModelValue($value);
Expand Down
16 changes: 10 additions & 6 deletions src/Model/Xml/Impl/Type/Attribute/EnumAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public function __construct(ModelElementTypeInterface $owningElementType, string
protected function convertXmlValueToModelValue(?string $rawValue)
{
if ($rawValue != null) {
$class = new ReflectionClass($this->type);
$value = $class->getConstant($rawValue);
return $value;
} else {
return null;
$class = new \ReflectionClass($this->type);
$constants = $class->getConstants();
if (in_array($rawValue, $constants)) {
return $rawValue;
}
}
return null;
}

/**
Expand All @@ -35,6 +36,9 @@ protected function convertModelValueToXmlValue($modelValue): string
{
$class = new \ReflectionClass($this->type);
$constants = $class->getConstants();
return array_search($modelValue, $constants);
if (in_array($modelValue, $constants)) {
return $modelValue;
}
return null;
}
}
Loading

0 comments on commit 8280a78

Please sign in to comment.