These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace gossi\swagger\collections; |
||
3 | |||
4 | use gossi\swagger\parts\RefPart; |
||
5 | use phootwork\collection\ArrayList; |
||
6 | use phootwork\collection\CollectionUtils; |
||
7 | use phootwork\lang\Arrayable; |
||
8 | use gossi\swagger\Parameter; |
||
9 | |||
10 | class Parameters implements Arrayable { |
||
11 | |||
12 | use RefPart; |
||
13 | |||
14 | /** @var ArrayList */ |
||
15 | private $parameters; |
||
16 | |||
17 | public function __construct($contents = null) { |
||
18 | $this->parse($contents === null ? new ArrayList() : $contents); |
||
19 | } |
||
20 | |||
21 | private function parse($contents) { |
||
22 | $data = CollectionUtils::toMap($contents); |
||
23 | |||
24 | $this->parameters = new ArrayList(); |
||
25 | $this->parseRef($data); |
||
26 | |||
27 | if (!$this->hasRef()) { |
||
28 | foreach ($data as $param) { |
||
29 | $this->parameters->add(new Parameter($param)); |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
34 | public function toArray() { |
||
35 | if ($this->hasRef()) { |
||
36 | return ['$ref' => $this->getRef()]; |
||
37 | } |
||
38 | |||
39 | return $this->parameters->toArray(); |
||
40 | } |
||
41 | |||
42 | public function size() { |
||
43 | return $this->parameters->size(); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Find parameter by name |
||
48 | * |
||
49 | * @param string $name |
||
50 | * @return Parameter |
||
51 | */ |
||
52 | public function findByName($name) { |
||
53 | return $this->search($name, function(Parameter $param, $name) { |
||
0 ignored issues
–
show
|
|||
54 | return $param->getName() == $name; |
||
55 | }); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Adds a parameter |
||
60 | * |
||
61 | * @param Parameter $param |
||
62 | */ |
||
63 | public function add(Parameter $param) { |
||
64 | $this->parameters->add($param); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Removes a parameter |
||
69 | * |
||
70 | * @param Parameter $param |
||
71 | */ |
||
72 | public function remove(Parameter $param) { |
||
73 | $this->parameters->remove($param); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Returns whether a given parameter exists |
||
78 | * |
||
79 | * @param Parameter $param |
||
80 | * @return boolean |
||
81 | */ |
||
82 | public function contains(Parameter $param) { |
||
83 | return $this->parameters->contains($param); |
||
84 | } |
||
85 | } |
||
86 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.