Test Setup Failed
Push — master ( 298fd3...56daff )
by Matthew
17:14
created

BaseJob::setRunId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Dtc\QueueBundle\Entity;
4
5
use Dtc\GridBundle\Annotation as Grid;
6
use Dtc\QueueBundle\Model\Job;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Dtc\QueueBundle\Entity\Job.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
7
use Doctrine\ORM\Mapping as ORM;
8
9
abstract class BaseJob extends Job
10
{
11
    /**
12
     * @Grid\Column()
13
     * @ORM\Column(type="bigint")
14
     * @ORM\Id
15
     * @ORM\GeneratedValue(strategy="AUTO")
16
     */
17
    protected $id;
18
19
    /**
20
     * @Grid\Column(sortable=true, searchable=true)
21
     * @ORM\Column(type="string")
22
     */
23
    protected $workerName;
24
25
    /**
26
     * @Grid\Column(sortable=true, searchable=true)
27
     * @ORM\Column(type="string")
28
     */
29
    protected $className;
30
31
    /**
32
     * @Grid\Column(sortable=true, searchable=true)
33
     * @ORM\Column(type="string")
34
     */
35
    protected $method;
36
37
    /**
38
     * @Grid\Column(sortable=true, searchable=true)
39
     * @ORM\Column(type="string")
40
     */
41
    protected $status;
42
43
    /**
44
     * @ORM\Column(type="text")
45
     */
46
    protected $args;
47
48
    /**
49
     * @ORM\Column(type="boolean", nullable=true)
50
     */
51
    protected $batch;
52
53
    /**
54
     * @Grid\Column(sortable=true, searchable=true)
55
     * @ORM\Column(type="boolean", nullable=true)
56
     */
57
    protected $locked;
58
59
    /**
60
     * @ORM\Column(type="datetime", nullable=true)
61
     */
62
    protected $lockedAt;
63
64
    /**
65
     * @Grid\Column(sortable=true)
66
     * @ORM\Column(type="integer", nullable=true)
67
     */
68
    protected $priority;
69
70
    /**
71
     * @ORM\Column(type="string")
72
     */
73
    protected $crcHash;
74
75
    /**
76
     * @Grid\Column(sortable=true)
77
     * @ORM\Column(type="datetime", nullable=true)
78
     */
79
    protected $whenAt;
80
81
    /**
82
     * @Grid\Column(sortable=true)
83
     * @ORM\Column(type="datetime", nullable=true)
84
     */
85
    protected $expiresAt;
86
87
    /**
88
     * When the job started.
89
     *
90
     * @Grid\Column(sortable=true)
91
     * @ORM\Column(type="datetime", nullable=true)
92
     */
93
    protected $startedAt;
94
95
    /**
96
     * When the job finished.
97
     *
98
     * @ORM\Column(type="datetime", nullable=true)
99
     */
100
    protected $finishedAt;
101
102
    /**
103
     * @ORM\Column(type="float", nullable=true)
104
     */
105
    protected $elapsed;
106
107
    /**
108
     * @ORM\Column(type="text", nullable=true)
109
     */
110
    protected $message;
111
112
    /**
113
     * @ORM\Column(type="datetime")
114
     */
115
    protected $createdAt;
116
117
    /**
118
     * @ORM\Column(type="datetime")
119
     */
120
    protected $updatedAt;
121
122
    /**
123
     * @ORM\Column(type="integer", nullable=true)
124
     */
125
    protected $maxDuration;
126
127
    /**
128
     * @ORM\Column(type="bigint", nullable=true)
129
     */
130
    protected $runId;
131
132
    /**
133
     * @return mixed
134
     */
135
    public function getRunId()
136
    {
137
        return $this->runId;
138
    }
139
140
    /**
141
     * @param mixed $runId
142
     */
143
    public function setRunId($runId)
144
    {
145
        $this->runId = $runId;
146
    }
147
148
    public function setArgs($args)
149
    {
150
        $args = serialize($args);
151
        parent::setArgs($args);
152
    }
153
154
    public function getArgs()
155
    {
156
        $args = parent::getArgs();
157
158
        return unserialize($args);
159
    }
160
}
161