public function testGetPropertyKeysReturnsContentOfStaticArray() { $this->assertSame($this->getStaticAttribute('\\Dkd\\PhpCmis\\Bindings\\Browser\\JSONConstants', 'PROPERTY_KEYS'), JSONConstants::getPropertyKeys()); }
/** * @param array|null $data * @param array $extensions * @return null|Properties * @throws CmisRuntimeException */ public function convertProperties(array $data = null, $extensions = array()) { if (empty($data)) { return null; } $properties = new Properties(); foreach ($data as $propertyData) { $id = !empty($propertyData[JSONConstants::JSON_PROPERTY_ID]) ? $propertyData[JSONConstants::JSON_PROPERTY_ID] : null; $queryName = !empty($propertyData[JSONConstants::JSON_PROPERTY_QUERYNAME]) ? $propertyData[JSONConstants::JSON_PROPERTY_QUERYNAME] : null; // A Property must always have an ID except if it used in a query result. // In a query result a Property should have an ID and must have a query name. if ($id === null && $queryName === null) { throw new CmisRuntimeException('Invalid property! Neither a property ID nor a query name is provided!'); } try { $propertyType = PropertyType::cast($propertyData[JSONConstants::JSON_PROPERTY_DATATYPE]); } catch (InvalidEnumerationValueException $exception) { throw new CmisRuntimeException(sprintf('Unknown property type "%s"!', $propertyData[JSONConstants::JSON_PROPERTY_DATATYPE])); } if (empty($propertyData[JSONConstants::JSON_PROPERTY_VALUE])) { $propertyValues = array(); } elseif (!is_array($propertyData[JSONConstants::JSON_PROPERTY_VALUE])) { $propertyValues = array($propertyData[JSONConstants::JSON_PROPERTY_VALUE]); } else { $propertyValues = $propertyData[JSONConstants::JSON_PROPERTY_VALUE]; } // get property keys without JSON-response-specific cardinality properties $jsonPropertyKeys = JSONConstants::getPropertyKeys(); $propertyKeys = array_values(array_diff($jsonPropertyKeys, array(JSONConstants::JSON_PROPERTY_CARDINALITY, JSONConstants::JSON_PROPERTY_VALUE, JSONConstants::JSON_PROPERTY_ID, JSONConstants::JSON_PROPERTY_DATATYPE))); $property = $this->getPropertyByPropertyType($propertyType, $id, $propertyValues); $property->populate($propertyData, $propertyKeys, true); $property->setExtensions($this->convertExtension($propertyData, $jsonPropertyKeys)); $properties->addProperty($property); } if (!empty($extensions)) { $properties->setExtensions($this->convertExtension($extensions)); } return $properties; }