These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Hateoas\Representation; |
||
4 | |||
5 | use Hateoas\Configuration\Annotation as Hateoas; |
||
6 | use JMS\Serializer\Annotation as Serializer; |
||
7 | |||
8 | /** |
||
9 | * @Serializer\ExclusionPolicy("all") |
||
10 | * |
||
11 | * @Hateoas\Relation( |
||
12 | * "self", |
||
13 | * href = @Hateoas\Route( |
||
14 | * "expr(object.getRoute())", |
||
15 | * parameters = "expr(object.getParameters())", |
||
16 | * absolute = "expr(object.isAbsolute())" |
||
17 | * ) |
||
18 | * ) |
||
19 | * |
||
20 | * @author Adrien Brault <[email protected]> |
||
21 | */ |
||
22 | View Code Duplication | class RouteAwareRepresentation |
|
0 ignored issues
–
show
|
|||
23 | { |
||
24 | /** |
||
25 | * @Serializer\Inline |
||
26 | * @Serializer\Expose |
||
27 | */ |
||
28 | private $inline; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $route; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $parameters; |
||
39 | |||
40 | /** |
||
41 | * @var boolean |
||
42 | */ |
||
43 | private $absolute; |
||
44 | |||
45 | public function __construct($inline, $route, array $parameters = array(), $absolute = false) |
||
46 | { |
||
47 | $this->inline = $inline; |
||
48 | $this->route = $route; |
||
49 | $this->parameters = $parameters; |
||
50 | $this->absolute = $absolute; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return mixed |
||
55 | */ |
||
56 | public function getInline() |
||
57 | { |
||
58 | return $this->inline; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getRoute() |
||
65 | { |
||
66 | return $this->route; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return array |
||
71 | */ |
||
72 | public function getParameters() |
||
73 | { |
||
74 | return $this->parameters; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return boolean |
||
79 | */ |
||
80 | public function isAbsolute() |
||
81 | { |
||
82 | return $this->absolute; |
||
83 | } |
||
84 | } |
||
85 |
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.