@@ -19,32 +19,32 @@ discard block |
||
| 19 | 19 | public function __invoke($var) |
| 20 | 20 | { |
| 21 | 21 | $data = file_get_contents($this->path); |
| 22 | - if(!$data) { |
|
| 22 | + if (!$data) { |
|
| 23 | 23 | throw new \RuntimeException(sprintf('Failed to read file at path %s!', $this->path)); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $yaml = Yaml::parse($data); |
| 27 | 27 | $keys = array_keys($yaml); |
| 28 | 28 | $yaml = $yaml[$keys[0]]; |
| 29 | - if(!$yaml) { |
|
| 30 | - throw new \InvalidArgumentException('No config at '.$this->path); |
|
| 29 | + if (!$yaml) { |
|
| 30 | + throw new \InvalidArgumentException('No config at ' . $this->path); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | $hasPolicy = array_key_exists('exclusion_policy', $yaml); |
| 34 | - if(!$hasPolicy || ($hasPolicy && 'ALL' !== $yaml['exclusion_policy'])) { |
|
| 34 | + if (!$hasPolicy || ($hasPolicy && 'ALL' !== $yaml['exclusion_policy'])) { |
|
| 35 | 35 | throw new \RuntimeException(sprintf('This serializer supports only ALL, %s given!', $yaml['exclusion_policy'])); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $ref = new \ReflectionObject($var); |
| 39 | 39 | $result = []; |
| 40 | - foreach($yaml['properties'] as $key => $config) { |
|
| 41 | - if($config['expose'] !== true) { |
|
| 40 | + foreach ($yaml['properties'] as $key => $config) { |
|
| 41 | + if ($config['expose'] !== true) { |
|
| 42 | 42 | continue; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $name = array_key_exists('serialized_name', $config) ? $config['serialized_name'] : $key; |
| 46 | 46 | |
| 47 | - if($ref->hasProperty($key)) { |
|
| 47 | + if ($ref->hasProperty($key)) { |
|
| 48 | 48 | $prop = $ref->getProperty($key); |
| 49 | 49 | $prop->setAccessible(true); |
| 50 | 50 | |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $method = 'get'.ucfirst($key); |
|
| 57 | - if(method_exists($var, $method)) { |
|
| 56 | + $method = 'get' . ucfirst($key); |
|
| 57 | + if (method_exists($var, $method)) { |
|
| 58 | 58 | $result[$name] = call_user_func_array([$var, $method], []); |
| 59 | 59 | |
| 60 | 60 | continue; |
@@ -18,8 +18,8 @@ |
||
| 18 | 18 | $ref = new \ReflectionObject($var); |
| 19 | 19 | |
| 20 | 20 | $result = []; |
| 21 | - foreach($ref->getProperties() as $property) { |
|
| 22 | - if(in_array($property->getName(), $this->skipped)) { |
|
| 21 | + foreach ($ref->getProperties() as $property) { |
|
| 22 | + if (in_array($property->getName(), $this->skipped)) { |
|
| 23 | 23 | continue; |
| 24 | 24 | } |
| 25 | 25 | |