1 | <?php namespace Cerbero\Workflow\Inflectors; |
||
10 | class Inflector implements InflectorInterface { |
||
11 | |||
12 | /** |
||
13 | * @author Andrea Marco Sartori |
||
14 | * @var string $word Word to inflect. |
||
15 | */ |
||
16 | protected $word; |
||
17 | |||
18 | /** |
||
19 | * @author Andrea Marco Sartori |
||
20 | * @var string $namespace The application namespace. |
||
21 | */ |
||
22 | protected $namespace; |
||
23 | |||
24 | /** |
||
25 | * Set the application namespace. |
||
26 | * |
||
27 | * @author Andrea Marco Sartori |
||
28 | * @param Cerbero\Workflow\Wrappers\NamespaceDetectorInterface $detector Application namespace detector. |
||
29 | * @return void |
||
|
|||
30 | */ |
||
31 | public function __construct(NamespaceDetectorInterface $detector) |
||
35 | |||
36 | /** |
||
37 | * Set the word to inflect. |
||
38 | * |
||
39 | * @author Andrea Marco Sartori |
||
40 | * @param string $word |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function of($word) |
||
44 | { |
||
45 | $this->word = $word; |
||
46 | |||
47 | return $this; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Retrieve the inflected request. |
||
52 | * |
||
53 | * @author Andrea Marco Sartori |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getRequest() |
||
60 | |||
61 | /** |
||
62 | * Compose the word to inflect. |
||
63 | * |
||
64 | * @author Andrea Marco Sartori |
||
65 | * @param string $suffix |
||
66 | * @param string $path |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function compose($suffix, $path) |
||
70 | { |
||
71 | $name = ucfirst($this->word) . $suffix; |
||
72 | |||
73 | return $this->namespace . "\\{$path}\\{$name}"; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Retrieve the inflected job. |
||
78 | * |
||
79 | * @author Andrea Marco Sartori |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getJob() |
||
86 | |||
87 | } |
||
88 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.