|
1
|
|
|
<?php |
|
2
|
|
|
namespace OmnideskBundle\Factory\Staff; |
|
3
|
|
|
|
|
4
|
|
|
use OmnideskBundle\Configuration\Staff\AddStaffRequestConfiguration; |
|
5
|
|
|
use OmnideskBundle\Configuration\Staff\EditStaffRequestConfiguration; |
|
6
|
|
|
use OmnideskBundle\Configuration\Staff\ListStaffRequestConfiguration; |
|
7
|
|
|
use OmnideskBundle\Configuration\Staff\ViewStaffRequestConfiguration; |
|
8
|
|
|
use OmnideskBundle\Exception\BadConfigurationFactoryException; |
|
9
|
|
|
use OmnideskBundle\Factory\AbstractConfigurationFactory; |
|
10
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class StaffConfigurationFactory |
|
14
|
|
|
* @package OmnideskBundle\Factory\Staff |
|
15
|
|
|
*/ |
|
16
|
|
View Code Duplication |
class StaffConfigurationFactory extends AbstractConfigurationFactory |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* StaffConfigurationFactory constructor. |
|
20
|
|
|
* @param AddStaffRequestConfiguration $addConfiguration |
|
21
|
|
|
* @param EditStaffRequestConfiguration $editConfiguration |
|
22
|
|
|
* @param ListStaffRequestConfiguration $listConfiguration |
|
23
|
|
|
* @param ViewStaffRequestConfiguration $viewConfiguration |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct( |
|
26
|
|
|
AddStaffRequestConfiguration $addConfiguration, |
|
27
|
|
|
EditStaffRequestConfiguration $editConfiguration, |
|
28
|
|
|
ListStaffRequestConfiguration $listConfiguration, |
|
29
|
|
|
ViewStaffRequestConfiguration $viewConfiguration |
|
30
|
|
|
) { |
|
31
|
|
|
$this->addConfiguration = $addConfiguration; |
|
32
|
|
|
$this->editConfiguration = $editConfiguration; |
|
33
|
|
|
$this->listConfiguration = $listConfiguration; |
|
34
|
|
|
$this->viewConfiguration = $viewConfiguration; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param string $type |
|
39
|
|
|
* @return ConfigurationInterface |
|
40
|
|
|
* @throws BadConfigurationFactoryException |
|
41
|
|
|
*/ |
|
42
|
|
|
public function get($type) |
|
43
|
|
|
{ |
|
44
|
|
|
switch ($type) { |
|
45
|
|
|
case self::CONFIGURATION_ADD: |
|
46
|
|
|
return $this->addConfiguration; |
|
47
|
|
|
case self::CONFIGURATION_EDIT: |
|
48
|
|
|
return $this->editConfiguration; |
|
49
|
|
|
case self::CONFIGURATION_LIST: |
|
50
|
|
|
return $this->listConfiguration; |
|
51
|
|
|
case self::CONFIGURATION_VIEW: |
|
52
|
|
|
return $this->viewConfiguration; |
|
53
|
|
|
default: |
|
54
|
|
|
throw new BadConfigurationFactoryException(); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.