Пример #1
0
 public function testHiddenProperties()
 {
     $this->mapping->setHiddenProperties(['propertyName']);
     $this->assertEquals(['propertyName'], $this->mapping->getHiddenProperties());
     $this->mapping->hideProperty('secondProperty');
     $this->assertEquals(['propertyName', 'secondProperty'], $this->mapping->getHiddenProperties());
 }
 /**
  * @param array   $mappedClass
  * @param Mapping $mapping
  * @param string  $className
  *
  * @throws MappingException
  */
 protected static function setHideProperties(array &$mappedClass, Mapping $mapping, string $className)
 {
     if (false === empty($mappedClass[static::HIDE_PROPERTIES_KEY])) {
         $mapping->setHiddenProperties($mappedClass[static::HIDE_PROPERTIES_KEY]);
         foreach ($mapping->getHiddenProperties() as $propertyName) {
             if (false === \in_array($propertyName, static::getClassProperties($className), true)) {
                 throw new MappingException(\sprintf('Could not hide property %s in class %s because it does not exist.', $propertyName, $className));
             }
         }
     }
 }