| Conditions | 3 |
| Paths | 3 |
| Total Lines | 11 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 6 | public function __construct($legislatureData, $country) |
|
| 17 | { |
||
| 18 | 6 | $properties = ['name', 'slug', 'personCount', 'sha', 'statementCount', 'popoloUrl']; |
|
| 19 | 6 | foreach ($properties as $k) { |
|
| 20 | 6 | $this->$k = array_key_exists($k, $legislatureData) ? $legislatureData[$k] : null; |
|
| 21 | 4 | } |
|
| 22 | 6 | $timestamp = $legislatureData['lastmod']; |
|
| 23 | 6 | $this->lastmod = \DateTime::createFromFormat('U', $timestamp); |
|
|
|
|||
| 24 | 6 | $this->legislatureData = $legislatureData; |
|
| 25 | 6 | $this->country = $country; |
|
| 26 | 6 | } |
|
| 27 | |||
| 29 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: