| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 | */ | 
| 52 | 52 | public function setPk(string $id) | 
| 53 | 53 |      { | 
| 54 | -        if(!empty($this->_id)) { | |
| 54 | +        if (!empty($this->_id)) { | |
| 55 | 55 |              throw new NOSQLValidationException(t('Primary key already defined'), NOSQLValidationException::NOSQL_VALIDATION_ID_ALREADY_DEFINED); | 
| 56 | 56 | } | 
| 57 | 57 | $this->_id = $id; | 
| @@ -64,7 +64,7 @@ discard block | ||
| 64 | 64 | public function getLastUpdate($format = null) | 
| 65 | 65 |      { | 
| 66 | 66 | $value = $this->_last_update; | 
| 67 | -        if(null !== $format) { | |
| 67 | +        if (null !== $format) { | |
| 68 | 68 | |
| 69 | 69 | } | 
| 70 | 70 | return $value; | 
| @@ -104,11 +104,11 @@ discard block | ||
| 104 | 104 |      public function validate($throwException = false) { | 
| 105 | 105 | $errors = []; | 
| 106 | 106 | $reflection = new \ReflectionClass(get_called_class()); | 
| 107 | -        foreach($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { | |
| 107 | +        foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { | |
| 108 | 108 | $required = InjectorHelper::checkIsRequired($property->getDocComment()); | 
| 109 | 109 | $value = $property->getValue($this); | 
| 110 | -            if($required && $this->checkEmpty($value)) { | |
| 111 | -                if($throwException) { | |
| 110 | +            if ($required && $this->checkEmpty($value)) { | |
| 111 | +                if ($throwException) { | |
| 112 | 112 |                      throw new NOSQLValidationException(t('Empty value for property ') . $property->getName(), NOSQLValidationException::NOSQL_VALIDATION_REQUIRED); | 
| 113 | 113 |                  } else { | 
| 114 | 114 | $errors[] = $property->getName(); | 
| @@ -127,10 +127,10 @@ discard block | ||
| 127 | 127 | public function toArray() | 
| 128 | 128 |      { | 
| 129 | 129 | $array = parent::toArray(); | 
| 130 | -        if(null !== $this->getPk()) { | |
| 130 | +        if (null !== $this->getPk()) { | |
| 131 | 131 | $array['_id'] = $this->getPk(); | 
| 132 | 132 | } | 
| 133 | -        if(null !== $this->getName()) { | |
| 133 | +        if (null !== $this->getName()) { | |
| 134 | 134 | $array[Api::API_LIST_NAME_FIELD] = $this->getName(); | 
| 135 | 135 | } | 
| 136 | 136 | $array['_last_update'] = $this->getLastUpdate(\DateTime::ATOM); | 
| @@ -154,10 +154,10 @@ discard block | ||
| 154 | 154 |                  if (!is_numeric($value)) { | 
| 155 | 155 | $errors[] = $property->getName(); | 
| 156 | 156 |                  } else { | 
| 157 | -                    if(NOSQLBase::NOSQL_TYPE_INTEGER === strtolower($type)) { | |
| 158 | - $property->setValue($this, (integer)$value); | |
| 157 | +                    if (NOSQLBase::NOSQL_TYPE_INTEGER === strtolower($type)) { | |
| 158 | + $property->setValue($this, (integer) $value); | |
| 159 | 159 |                      } else { | 
| 160 | - $property->setValue($this, (float)$value); | |
| 160 | + $property->setValue($this, (float) $value); | |
| 161 | 161 | } | 
| 162 | 162 | } | 
| 163 | 163 | break; | 
| @@ -179,16 +179,16 @@ discard block | ||
| 179 | 179 |                  if (!in_array($value, [true, false, 0, 1])) { | 
| 180 | 180 | $errors[] = $property->getName(); | 
| 181 | 181 | } | 
| 182 | - $property->setValue($this, (bool)$value); | |
| 182 | + $property->setValue($this, (bool) $value); | |
| 183 | 183 | break; | 
| 184 | 184 | case NOSQLBase::NOSQL_TYPE_DATE: | 
| 185 | 185 | case NOSQLBase::NOSQL_TYPE_TIMESTAMP: | 
| 186 | 186 |                  $dateTime = new \DateTime($value, new \DateTimeZone('UTC')); | 
| 187 | -                if(!$dateTime) { | |
| 187 | +                if (!$dateTime) { | |
| 188 | 188 | $errors[] = $property->getName(); | 
| 189 | 189 |                  } else { | 
| 190 | 190 | $dateTime->setTimezone(new \DateTimeZone(date_default_timezone_get())); | 
| 191 | - $property->setValue($this, new UTCDateTime($dateTime->getTimestamp()*1000)); | |
| 191 | + $property->setValue($this, new UTCDateTime($dateTime->getTimestamp() * 1000)); | |
| 192 | 192 | } | 
| 193 | 193 | break; | 
| 194 | 194 | } | 
| @@ -24,7 +24,7 @@ discard block | ||
| 24 | 24 | public function __get($name) | 
| 25 | 25 |      { | 
| 26 | 26 | $value = null; | 
| 27 | -        if(null !== $this->dto && property_exists($this->dto, $name)) { | |
| 27 | +        if (null !== $this->dto && property_exists($this->dto, $name)) { | |
| 28 | 28 | $value = $this->dto->$name; | 
| 29 | 29 | } | 
| 30 | 30 | return $value; | 
| @@ -36,7 +36,7 @@ discard block | ||
| 36 | 36 | */ | 
| 37 | 37 | public function __set($name, $value) | 
| 38 | 38 |      { | 
| 39 | -        if(null !== $this->dto && property_exists($this->dto, $name)) { | |
| 39 | +        if (null !== $this->dto && property_exists($this->dto, $name)) { | |
| 40 | 40 | $this->dto->$name = $value; | 
| 41 | 41 | $this->addChanges($name); | 
| 42 | 42 | } | 
| @@ -45,9 +45,9 @@ discard block | ||
| 45 | 45 | |
| 46 | 46 | public function __call($name, $arguments) | 
| 47 | 47 |      { | 
| 48 | -        if(preg_match('/^(set|get)/', $name)) { | |
| 48 | +        if (preg_match('/^(set|get)/', $name)) { | |
| 49 | 49 | $property = lcfirst(str_replace(['set', 'Set', 'get', 'Get'], '', $name)); | 
| 50 | -            if(false !== stripos($name, 'set')) { | |
| 50 | +            if (false !== stripos($name, 'set')) { | |
| 51 | 51 | $this->dto->$property = $arguments[0]; | 
| 52 | 52 |              } else { | 
| 53 | 53 | return $this->dto->$property; | 
| @@ -64,11 +64,11 @@ discard block | ||
| 64 | 64 |      public function feed(array $data, $withName = false) { | 
| 65 | 65 | $name = ''; | 
| 66 | 66 | $sep = ''; | 
| 67 | -        foreach($data as $key => $value) { | |
| 68 | -            if($value instanceof ObjectId) { | |
| 67 | +        foreach ($data as $key => $value) { | |
| 68 | +            if ($value instanceof ObjectId) { | |
| 69 | 69 | $this->dto->setPk($value->jsonSerialize()['$oid']); | 
| 70 | 70 | $name = $this->dto->getPk(); | 
| 71 | -            } elseif($key === '_last_update') { | |
| 71 | +            } elseif ($key === '_last_update') { | |
| 72 | 72 | $this->dto->setLastUpdate($value instanceof UTCDateTime ? $value : null); | 
| 73 | 73 |              } else { | 
| 74 | 74 |                  if (is_object($value)) { | 
| @@ -79,13 +79,13 @@ discard block | ||
| 79 | 79 | } | 
| 80 | 80 | } | 
| 81 | 81 | $this->$key = $value; | 
| 82 | -                if(in_array(strtolower($key), ['name', 'label', 'title', 'method'])) { | |
| 82 | +                if (in_array(strtolower($key), ['name', 'label', 'title', 'method'])) { | |
| 83 | 83 | $name .= $sep . $value; | 
| 84 | 84 | $sep = ' '; | 
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 | } | 
| 88 | -        if($withName) { | |
| 88 | +        if ($withName) { | |
| 89 | 89 | $this->dto->setName($name); | 
| 90 | 90 | } | 
| 91 | 91 | } |