1 | <?php namespace Cerbero\Workflow\Console\Commands; |
||
8 | trait AttachesPipesTrait { |
||
9 | |||
10 | /** |
||
11 | * @author Andrea Marco Sartori |
||
12 | * @var string $currentPipe Pipe to generate. |
||
13 | */ |
||
14 | protected $currentPipe; |
||
15 | |||
16 | /** |
||
17 | * Generate the specified pipes. |
||
18 | * |
||
19 | * @author Andrea Marco Sartori |
||
20 | * @return void |
||
21 | */ |
||
22 | protected function generatePipes() |
||
23 | { |
||
24 | foreach ($this->getPipesByOption('attach') as $pipe) |
||
25 | { |
||
26 | $this->currentPipe = $pipe; |
||
27 | |||
28 | parent::fire(); |
||
|
|||
29 | } |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Retrieve a list of pipes. |
||
34 | * |
||
35 | * @author Andrea Marco Sartori |
||
36 | * @param string $option |
||
37 | * @return array |
||
38 | */ |
||
39 | protected function getPipesByOption($option) |
||
40 | { |
||
41 | $pipes = $this->option($option); |
||
42 | |||
43 | preg_match_all('/\w+/', $pipes, $matches); |
||
44 | |||
45 | return array_map('ucfirst', $matches[0]); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get the default namespace for the class. |
||
50 | * |
||
51 | * @param string $rootNamespace |
||
52 | * @return string |
||
53 | */ |
||
54 | protected function getDefaultNamespace($rootNamespace) |
||
55 | { |
||
56 | $workflows = $this->getWorkflowsNamespace(); |
||
57 | |||
58 | $pipeline = $this->getWorkflowName(); |
||
59 | |||
60 | return "{$rootNamespace}\\{$workflows}\\{$pipeline}"; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Retrieve the namespace of the workflows. |
||
65 | * |
||
66 | * @author Andrea Marco Sartori |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function getWorkflowsNamespace() |
||
70 | { |
||
71 | $relative = ltrim(config('workflow.path'), app_path()); |
||
72 | |||
73 | $chunks = array_map('ucfirst', explode('/', $relative)); |
||
74 | |||
75 | return implode('\\', $chunks); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Retrieve a list of pipes with their namespaces. |
||
80 | * |
||
81 | * @author Andrea Marco Sartori |
||
82 | * @param string $option |
||
83 | * @return array |
||
84 | */ |
||
85 | protected function getNamespacedPipesByOption($option) |
||
89 | |||
90 | /** |
||
91 | * Get the desired class name from the input. |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function getNameInput() |
||
99 | |||
100 | } |
||
101 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.