/**
  * throw exception if entity is not valid
  * @param IEntity $entity
  * @throws Exception
  */
 protected function checkIsValid(IEntity $entity)
 {
     if (!$entity->isValid()) {
         $msg = Utility::getClassName($entity) . ' is not valid';
         throw new Exception($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
     }
 }
 /**
  * generate output for one backend
  *
  * @param IEntity $entity
  * @return array
  */
 protected function generate(IEntity $entity)
 {
     $data = [];
     $properties = Utility::getPublicProperties($entity);
     foreach ($properties as $key => $value) {
         $getter = 'get' . ucfirst($key);
         $value = $entity->{$getter}();
         $this->setProperty($data, strtolower($key), $value);
     }
     return $data;
 }
Example #3
0
 /**
  * checks if current object contains null values
  *
  * @return boolean
  */
 public function doesContainNullValues()
 {
     return in_array(null, Utility::getPublicProperties($this));
 }