Passed
Push — develop ( 49c268...06f5f0 )
by Nikita
04:50
created

GdaemonTasksController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 47
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A output() 0 6 1
A get() 0 10 1
1
<?php
2
3
namespace Gameap\Http\Controllers\API;
4
5
use Gameap\Http\Controllers\AuthController;
6
use Gameap\Repositories\GdaemonTaskRepository;
7
use Gameap\Models\GdaemonTask;
8
9
class GdaemonTasksController extends AuthController
10
{
11
    /**
12
     * The GdaemonTaskRepository instance.
13
     *
14
     * @var \Gameap\Repositories\GdaemonTaskRepository
15
     */
16
    public $repository;
17
18
    /**
19
     * GdaemonTasksController constructor.
20
     * @param GdaemonTaskRepository $repository
21
     */
22
    public function __construct(GdaemonTaskRepository $repository)
23
    {
24
        parent::__construct();
25
26
        $this->repository = $repository;
27
    }
28
29
    /**
30
     * @param GdaemonTask $gdaemonTask
31
     * @return array
32
     */
33
    public function get(GdaemonTask $gdaemonTask)
34
    {
35
        return [
36
            'id' => $gdaemonTask->id,
37
            'run_aft_id' => $gdaemonTask->id,
38
            'created_at' => $gdaemonTask->created_at->toDateTimeString(),
0 ignored issues
show
Bug introduced by
The method toDateTimeString() does not exist on DateTime. It seems like you code against a sub-type of DateTime such as Carbon\Carbon. ( Ignorable by Annotation )

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

38
            'created_at' => $gdaemonTask->created_at->/** @scrutinizer ignore-call */ toDateTimeString(),
Loading history...
39
            'updated_at' => $gdaemonTask->updated_at->toDateTimeString(),
40
            'server_id' => $gdaemonTask->server_id,
41
            'task' => $gdaemonTask->task,
42
            'status' => $gdaemonTask->status,
43
        ];
44
    }
45
46
    /**
47
     * @param GdaemonTask $gdaemonTask
48
     * @return array
49
     */
50
    public function output(GdaemonTask $gdaemonTask)
51
    {
52
        return [
53
            'id' => $gdaemonTask->id,
54
            'output' => $gdaemonTask->output,
55
            'status' => $gdaemonTask->status,
56
        ];
57
    }
58
}