1 | <?php |
||
29 | class JobClass implements ContainerAwareInterface |
||
30 | { |
||
31 | /** |
||
32 | * @var string |
||
33 | * |
||
34 | * Default description when is not defined |
||
35 | */ |
||
36 | const DEFAULT_DESCRIPTION = 'No description is defined'; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | * |
||
41 | * Callable name for this job |
||
42 | * If is setted on annotations, this value will be used |
||
43 | * otherwise, natural method name will be used. |
||
44 | */ |
||
45 | private $callableName; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | * |
||
50 | * Method name |
||
51 | */ |
||
52 | private $methodName; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | * |
||
57 | * RealCallable name for this job without the job prefix |
||
58 | * |
||
59 | */ |
||
60 | private $realCallableNameNoPrefix; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | * |
||
65 | * RealCallable name for this job |
||
66 | * natural method name will be used. |
||
67 | */ |
||
68 | private $realCallableName; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | * |
||
73 | * Description of Job |
||
74 | */ |
||
75 | private $description; |
||
76 | |||
77 | /** |
||
78 | * @var integer |
||
79 | * |
||
80 | * Number of iterations this job will be alive before die |
||
81 | */ |
||
82 | private $iterations; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | * |
||
87 | * Default method this job will be call into Gearman client |
||
88 | */ |
||
89 | private $defaultMethod; |
||
90 | |||
91 | /** |
||
92 | * @var int |
||
93 | * |
||
94 | * Job minimum execution time |
||
95 | */ |
||
96 | private $minimumExecutionTime; |
||
97 | |||
98 | /** |
||
99 | * @var int |
||
100 | * |
||
101 | * Timeout for idle worker |
||
102 | */ |
||
103 | private $timeout; |
||
104 | |||
105 | /** |
||
106 | * @var array |
||
107 | * |
||
108 | * Collection of servers to connect |
||
109 | */ |
||
110 | private $servers; |
||
111 | |||
112 | /** |
||
113 | * @var string |
||
114 | * |
||
115 | * The prefix to be prepended to all job callable names. |
||
116 | */ |
||
117 | private $jobPrefix; |
||
118 | |||
119 | /** |
||
120 | * @var ContainerInterface |
||
121 | */ |
||
122 | protected $container; |
||
123 | |||
124 | /** |
||
125 | * Construct method |
||
126 | * |
||
127 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
128 | * @param ReflectionMethod $reflectionMethod ReflextionMethod class |
||
129 | * @param string $callableNameClass Callable name class |
||
130 | * @param array $servers Array of servers defined for Worker |
||
131 | * @param array $defaultSettings Default settings for Worker |
||
132 | */ |
||
133 | 18 | public function __construct( |
|
166 | |||
167 | /** |
||
168 | * Load servers |
||
169 | * |
||
170 | * If any server is defined in JobAnnotation, this one is used. |
||
171 | * Otherwise is used servers set in Class |
||
172 | * |
||
173 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
174 | * @param array $servers Array of servers defined for Worker |
||
175 | * |
||
176 | * @return array Servers |
||
177 | */ |
||
178 | 18 | private function loadServers(JobAnnotation $jobAnnotation, array $servers) |
|
193 | |||
194 | /** |
||
195 | * Load iterations |
||
196 | * |
||
197 | * If iterations is defined in JobAnnotation, this one is used. |
||
198 | * Otherwise is used set in Class |
||
199 | * |
||
200 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
201 | * @param array $defaultSettings Default settings for Worker |
||
202 | * |
||
203 | * @return integer Iteration |
||
204 | */ |
||
205 | 18 | private function loadIterations(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
211 | |||
212 | /** |
||
213 | * Load defaultMethod |
||
214 | * |
||
215 | * If defaultMethod is defined in JobAnnotation, this one is used. |
||
216 | * Otherwise is used set in Class |
||
217 | * |
||
218 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
219 | * @param array $defaultSettings Default settings for Worker |
||
220 | * |
||
221 | * @return string Default method |
||
222 | */ |
||
223 | 18 | private function loadDefaultMethod(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
229 | |||
230 | /** |
||
231 | * Load minimumExecutionTime |
||
232 | * |
||
233 | * If minimumExecutionTime is defined in JobAnnotation, this one is used. |
||
234 | * Otherwise is used set in Class |
||
235 | * |
||
236 | * @param JobAnnotation $jobAnnotation |
||
237 | * @param array $defaultSettings |
||
238 | * |
||
239 | * @return int |
||
240 | */ |
||
241 | 18 | private function loadMinimumExecutionTime(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
247 | |||
248 | /** |
||
249 | * Load timeout |
||
250 | * |
||
251 | * If timeout is defined in JobAnnotation, this one is used. |
||
252 | * Otherwise is used set in Class |
||
253 | * |
||
254 | * @param JobAnnotation $jobAnnotation |
||
255 | * @param array $defaultSettings |
||
256 | * |
||
257 | * @return int |
||
258 | */ |
||
259 | 18 | private function loadTimeout(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
265 | |||
266 | /** |
||
267 | * Retrieve all Job data in cache format |
||
268 | * |
||
269 | * @return array |
||
270 | */ |
||
271 | 18 | public function toArray() |
|
288 | |||
289 | /** |
||
290 | * Sets the container. |
||
291 | * |
||
292 | * @param ContainerInterface|null $container A ContainerInterface instance or null |
||
293 | */ |
||
294 | public function setContainer(ContainerInterface $container = null) |
||
298 | } |
||
299 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.