1 | <?php |
||
25 | class JobClass implements ContainerAwareInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var string |
||
29 | * |
||
30 | * Default description when is not defined |
||
31 | */ |
||
32 | const DEFAULT_DESCRIPTION = 'No description is defined'; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | * |
||
37 | * Callable name for this job |
||
38 | * If is setted on annotations, this value will be used |
||
39 | * otherwise, natural method name will be used. |
||
40 | */ |
||
41 | private $callableName; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | * |
||
46 | * Method name |
||
47 | */ |
||
48 | private $methodName; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | * |
||
53 | * RealCallable name for this job without the job prefix |
||
54 | * |
||
55 | */ |
||
56 | private $realCallableNameNoPrefix; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | * |
||
61 | * RealCallable name for this job |
||
62 | * natural method name will be used. |
||
63 | */ |
||
64 | private $realCallableName; |
||
65 | |||
66 | /** |
||
67 | * @var string |
||
68 | * |
||
69 | * Description of Job |
||
70 | */ |
||
71 | private $description; |
||
72 | |||
73 | /** |
||
74 | * @var integer |
||
75 | * |
||
76 | * Number of iterations this job will be alive before die |
||
77 | */ |
||
78 | private $iterations; |
||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | * |
||
83 | * Default method this job will be call into Gearman client |
||
84 | */ |
||
85 | private $defaultMethod; |
||
86 | |||
87 | /** |
||
88 | * @var int |
||
89 | * |
||
90 | * Job minimum execution time |
||
91 | */ |
||
92 | private $minimumExecutionTime; |
||
93 | |||
94 | /** |
||
95 | * @var int |
||
96 | * |
||
97 | * Timeout for idle worker |
||
98 | */ |
||
99 | private $timeout; |
||
100 | |||
101 | /** |
||
102 | * @var array |
||
103 | * |
||
104 | * Collection of servers to connect |
||
105 | */ |
||
106 | private $servers; |
||
107 | |||
108 | /** |
||
109 | * @var string |
||
110 | * |
||
111 | * The prefix to be prepended to all job callable names. |
||
112 | */ |
||
113 | private $jobPrefix; |
||
114 | |||
115 | /** |
||
116 | * @var ContainerInterface |
||
117 | */ |
||
118 | protected $container; |
||
119 | |||
120 | /** |
||
121 | * Construct method |
||
122 | * |
||
123 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
124 | * @param \ReflectionMethod $reflectionMethod ReflextionMethod class |
||
125 | * @param string $callableNameClass Callable name class |
||
126 | * @param array $servers Array of servers defined for Worker |
||
127 | * @param array $defaultSettings Default settings for Worker |
||
128 | */ |
||
129 | 6 | public function __construct( |
|
162 | |||
163 | /** |
||
164 | * Load servers |
||
165 | * |
||
166 | * If any server is defined in JobAnnotation, this one is used. |
||
167 | * Otherwise is used servers set in Class |
||
168 | * |
||
169 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
170 | * @param array $servers Array of servers defined for Worker |
||
171 | * |
||
172 | * @return array Servers |
||
173 | */ |
||
174 | 6 | private function loadServers(JobAnnotation $jobAnnotation, array $servers) |
|
189 | |||
190 | /** |
||
191 | * Load iterations |
||
192 | * |
||
193 | * If iterations is defined in JobAnnotation, this one is used. |
||
194 | * Otherwise is used set in Class |
||
195 | * |
||
196 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
197 | * @param array $defaultSettings Default settings for Worker |
||
198 | * |
||
199 | * @return integer Iteration |
||
200 | */ |
||
201 | 6 | private function loadIterations(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
207 | |||
208 | /** |
||
209 | * Load defaultMethod |
||
210 | * |
||
211 | * If defaultMethod is defined in JobAnnotation, this one is used. |
||
212 | * Otherwise is used set in Class |
||
213 | * |
||
214 | * @param JobAnnotation $jobAnnotation JobAnnotation class |
||
215 | * @param array $defaultSettings Default settings for Worker |
||
216 | * |
||
217 | * @return string Default method |
||
218 | */ |
||
219 | 6 | private function loadDefaultMethod(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
225 | |||
226 | /** |
||
227 | * Load minimumExecutionTime |
||
228 | * |
||
229 | * If minimumExecutionTime is defined in JobAnnotation, this one is used. |
||
230 | * Otherwise is used set in Class |
||
231 | * |
||
232 | * @param JobAnnotation $jobAnnotation |
||
233 | * @param array $defaultSettings |
||
234 | * |
||
235 | * @return int |
||
236 | */ |
||
237 | 6 | private function loadMinimumExecutionTime(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
243 | |||
244 | /** |
||
245 | * Load timeout |
||
246 | * |
||
247 | * If timeout is defined in JobAnnotation, this one is used. |
||
248 | * Otherwise is used set in Class |
||
249 | * |
||
250 | * @param JobAnnotation $jobAnnotation |
||
251 | * @param array $defaultSettings |
||
252 | * |
||
253 | * @return int |
||
254 | */ |
||
255 | 6 | private function loadTimeout(JobAnnotation $jobAnnotation, array $defaultSettings) |
|
261 | |||
262 | /** |
||
263 | * Retrieve all Job data in cache format |
||
264 | * |
||
265 | * @return array |
||
266 | */ |
||
267 | 6 | public function toArray() |
|
284 | |||
285 | /** |
||
286 | * Sets the container. |
||
287 | * |
||
288 | * @param ContainerInterface|null $container A ContainerInterface instance or null |
||
289 | */ |
||
290 | public function setContainer(ContainerInterface $container = null) |
||
294 | } |
||
295 |
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.