Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | public function createAlbum($data = null, $add = true) |
||
9 | { |
||
10 | $faker = \Faker\Factory::create(); |
||
11 | $album = new Entity\Album(); |
||
12 | $metadata = [ |
||
13 | 'id' => $faker->unique()->randomDigitNotNull(), |
||
14 | 'name' => $faker->name, |
||
15 | 'description' => $faker->sentence(3) |
||
16 | ]; |
||
17 | if(!is_null($data)) { |
||
18 | foreach ($data as $key => $value) { |
||
19 | $metadata[$key] = $value; |
||
20 | } |
||
21 | } |
||
22 | $album->map($metadata); |
||
23 | if($add) { |
||
24 | $this->albums->add($album); |
||
|
|||
25 | } |
||
26 | return $album; |
||
27 | } |
||
28 | |||
52 | } |
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: