Passed
Push — master ( 139939...b4b8e8 )
by Arthur
21:54 queued 17s
created

ScheduleTransformer::transformResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 13
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 29.10.18
6
 * Time: 09:38.
7
 */
8
9
namespace Modules\Schedule\Transformers;
10
11
use Foundation\Abstracts\Transformers\Transformer;
12
use Foundation\Exceptions\Exception;
13
use Modules\Schedule\Entities\Schedule;
14
use Modules\Machine\Transformers\MachineTransformer;
15
use Modules\User\Transformers\UserTransformer;
16
17
class ScheduleTransformer extends Transformer
18
{
19
    public $available = [
20
        'user' => UserTransformer::class
21
    ];
22
23
    /**
24
     * Transform the resource into an array.
25
     *
26
     * @throws Exception
27
     *
28
     * @return array
29
     */
30
    public function transformResource(Schedule $schedule)
31
    {
32
        return [
33
            'id' => $schedule->id,
34
            'alias' => $schedule->alias,
0 ignored issues
show
Bug introduced by
The property alias does not seem to exist on Modules\Schedule\Entities\Schedule. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
35
            'timezone' => $schedule->timezone,
0 ignored issues
show
Bug introduced by
The property timezone does not seem to exist on Modules\Schedule\Entities\Schedule. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
36
            'week_days' => $schedule->week_days,
0 ignored issues
show
Bug introduced by
The property week_days does not seem to exist on Modules\Schedule\Entities\Schedule. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
37
            'exceptions' => $schedule->exceptions,
0 ignored issues
show
Bug introduced by
The property exceptions does not seem to exist on Modules\Schedule\Entities\Schedule. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
38
            'randomize' => $schedule->randomize,
0 ignored issues
show
Bug introduced by
The property randomize does not seem to exist on Modules\Schedule\Entities\Schedule. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
39
            'times' => $schedule->times, //$this->buildTimes($schedule->week_days),
0 ignored issues
show
Bug introduced by
The property times does not exist on Modules\Schedule\Entities\Schedule. Did you mean timestamps?
Loading history...
40
            'accounts' => [],
41
            'created_at' => $schedule->created_at,
42
            'updated_at' => $schedule->updated_at
43
        ];
44
    }
45
46
    public function buildTimes($weekDays): array
0 ignored issues
show
Unused Code introduced by
The parameter $weekDays is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

46
    public function buildTimes(/** @scrutinizer ignore-unused */ $weekDays): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        return [];
49
    }
50
}
51