1
|
|
|
<?php |
2
|
|
|
namespace rtens\domin\reflection; |
3
|
|
|
|
4
|
|
|
use rtens\domin\reflection\types\TypeFactory; |
5
|
|
|
|
6
|
|
|
class GenericMethodAction extends MethodAction { |
7
|
|
|
|
8
|
|
|
/** @var GenericAction */ |
9
|
|
|
private $generic; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @param object $object |
13
|
|
|
* @param string $method |
14
|
|
|
* @param TypeFactory $types |
15
|
|
|
* @param CommentParser $parser |
16
|
|
|
*/ |
17
|
|
View Code Duplication |
public function __construct($object, $method, TypeFactory $types, CommentParser $parser) { |
|
|
|
|
18
|
|
|
parent::__construct($object, $method, $types, $parser); |
19
|
|
|
$this->generic = new GenericAction($this); |
20
|
|
|
$this->generic |
21
|
|
|
->setCaption(parent::caption()) |
|
|
|
|
22
|
|
|
->setDescription(parent::description()) |
|
|
|
|
23
|
|
|
->setParameters(parent::parameters()) |
|
|
|
|
24
|
|
|
->setExecute(function ($parameters) { |
25
|
|
|
return parent::execute($parameters); |
26
|
|
|
}) |
27
|
|
|
->setFill(function ($parameters) { |
28
|
|
|
return $parameters; |
29
|
|
|
}); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function generic() { |
33
|
|
|
return $this->generic; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function execute(array $parameters) { |
37
|
|
|
return $this->generic->execute($parameters); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function caption() { |
41
|
|
|
return $this->generic->caption(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function description() { |
45
|
|
|
return $this->generic->description(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function fill(array $parameters) { |
49
|
|
|
return $this->generic->fill(parent::fill($parameters)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function parameters() { |
53
|
|
|
return $this->generic->parameters(); |
54
|
|
|
} |
55
|
|
|
} |
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.