@@ -8,37 +8,37 @@ |
||
| 8 | 8 | |
| 9 | 9 | trait TagsPart |
| 10 | 10 | { |
| 11 | - private $tags; |
|
| 11 | + private $tags; |
|
| 12 | 12 | |
| 13 | - private function parseTags(Map $data) |
|
| 14 | - { |
|
| 15 | - $this->tags = new ArrayList(); |
|
| 16 | - foreach ($data->get('tags', []) as $t) { |
|
| 17 | - $this->tags->add(new Tag($t)); |
|
| 18 | - } |
|
| 19 | - } |
|
| 13 | + private function parseTags(Map $data) |
|
| 14 | + { |
|
| 15 | + $this->tags = new ArrayList(); |
|
| 16 | + foreach ($data->get('tags', []) as $t) { |
|
| 17 | + $this->tags->add(new Tag($t)); |
|
| 18 | + } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Return tags. |
|
| 23 | - * |
|
| 24 | - * @return ArrayList |
|
| 25 | - */ |
|
| 26 | - public function getTags() |
|
| 27 | - { |
|
| 28 | - return $this->tags; |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * Return tags. |
|
| 23 | + * |
|
| 24 | + * @return ArrayList |
|
| 25 | + */ |
|
| 26 | + public function getTags() |
|
| 27 | + { |
|
| 28 | + return $this->tags; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - protected function exportTags() |
|
| 32 | - { |
|
| 33 | - $out = []; |
|
| 34 | - foreach ($this->tags as $tag) { |
|
| 35 | - if ($tag->isObject()) { |
|
| 36 | - $out[] = $tag->toArray(); |
|
| 37 | - } else { |
|
| 38 | - $out[] = $tag->getName(); |
|
| 39 | - } |
|
| 40 | - } |
|
| 31 | + protected function exportTags() |
|
| 32 | + { |
|
| 33 | + $out = []; |
|
| 34 | + foreach ($this->tags as $tag) { |
|
| 35 | + if ($tag->isObject()) { |
|
| 36 | + $out[] = $tag->toArray(); |
|
| 37 | + } else { |
|
| 38 | + $out[] = $tag->getName(); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return $out; |
|
| 43 | - } |
|
| 42 | + return $out; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -6,12 +6,10 @@ discard block |
||
| 6 | 6 | use phootwork\collection\ArrayList; |
| 7 | 7 | use gossi\swagger\Tag; |
| 8 | 8 | |
| 9 | -trait TagsPart |
|
| 10 | -{ |
|
| 9 | +trait TagsPart { |
|
| 11 | 10 | private $tags; |
| 12 | 11 | |
| 13 | - private function parseTags(Map $data) |
|
| 14 | - { |
|
| 12 | + private function parseTags(Map $data) { |
|
| 15 | 13 | $this->tags = new ArrayList(); |
| 16 | 14 | foreach ($data->get('tags', []) as $t) { |
| 17 | 15 | $this->tags->add(new Tag($t)); |
@@ -23,13 +21,11 @@ discard block |
||
| 23 | 21 | * |
| 24 | 22 | * @return ArrayList |
| 25 | 23 | */ |
| 26 | - public function getTags() |
|
| 27 | - { |
|
| 24 | + public function getTags() { |
|
| 28 | 25 | return $this->tags; |
| 29 | 26 | } |
| 30 | 27 | |
| 31 | - protected function exportTags() |
|
| 32 | - { |
|
| 28 | + protected function exportTags() { |
|
| 33 | 29 | $out = []; |
| 34 | 30 | foreach ($this->tags as $tag) { |
| 35 | 31 | if ($tag->isObject()) { |
@@ -10,148 +10,148 @@ |
||
| 10 | 10 | |
| 11 | 11 | class Parameters implements Arrayable, \Iterator |
| 12 | 12 | { |
| 13 | - use RefPart; |
|
| 14 | - |
|
| 15 | - /** @var ArrayList */ |
|
| 16 | - private $parameters; |
|
| 17 | - |
|
| 18 | - public function __construct($contents = []) |
|
| 19 | - { |
|
| 20 | - $this->parse($contents === null ? [] : $contents); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - private function parse($contents) |
|
| 24 | - { |
|
| 25 | - $data = CollectionUtils::toMap($contents); |
|
| 26 | - |
|
| 27 | - $this->parameters = new ArrayList(); |
|
| 28 | - $this->parseRef($data); |
|
| 29 | - |
|
| 30 | - if (!$this->hasRef()) { |
|
| 31 | - foreach ($data as $param) { |
|
| 32 | - $this->parameters->add(new Parameter($param)); |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - public function toArray() |
|
| 38 | - { |
|
| 39 | - if ($this->hasRef()) { |
|
| 40 | - return ['$ref' => $this->getRef()]; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - return $this->parameters->toArray(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function size() |
|
| 47 | - { |
|
| 48 | - return $this->parameters->size(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Searches whether a parameter with the given name exists. |
|
| 53 | - * |
|
| 54 | - * @param string $name |
|
| 55 | - * |
|
| 56 | - * @return bool |
|
| 57 | - */ |
|
| 58 | - public function searchByName($name) |
|
| 59 | - { |
|
| 60 | - return $this->parameters->search($name, function (Parameter $param, $name) { |
|
| 61 | - return $param->getName() == $name; |
|
| 62 | - }); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Returns parameter with the given name if it exists. |
|
| 67 | - * |
|
| 68 | - * @param string $name |
|
| 69 | - * |
|
| 70 | - * @return Parameter|void |
|
| 71 | - */ |
|
| 72 | - public function findByName($name) |
|
| 73 | - { |
|
| 74 | - foreach ($this->parameters as $param) { |
|
| 75 | - if ($param->getName() == $name) { |
|
| 76 | - return $param; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Searches for the parameter with the given name. Creates a parameter with the given name |
|
| 83 | - * if none exists. |
|
| 84 | - * |
|
| 85 | - * @param string $name |
|
| 86 | - * |
|
| 87 | - * @return Parameter |
|
| 88 | - */ |
|
| 89 | - public function getByName($name) |
|
| 90 | - { |
|
| 91 | - $param = $this->findByName($name); |
|
| 92 | - if (empty($param)) { |
|
| 93 | - $param = new Parameter(); |
|
| 94 | - $param->setName($name); |
|
| 95 | - $this->parameters->add($param); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - return $param; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Adds a parameter. |
|
| 103 | - * |
|
| 104 | - * @param Parameter $param |
|
| 105 | - */ |
|
| 106 | - public function add(Parameter $param) |
|
| 107 | - { |
|
| 108 | - $this->parameters->add($param); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Removes a parameter. |
|
| 113 | - * |
|
| 114 | - * @param Parameter $param |
|
| 115 | - */ |
|
| 116 | - public function remove(Parameter $param) |
|
| 117 | - { |
|
| 118 | - $this->parameters->remove($param); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Returns whether a given parameter exists. |
|
| 123 | - * |
|
| 124 | - * @param Parameter $param |
|
| 125 | - * |
|
| 126 | - * @return bool |
|
| 127 | - */ |
|
| 128 | - public function contains(Parameter $param) |
|
| 129 | - { |
|
| 130 | - return $this->parameters->contains($param); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - public function current() |
|
| 134 | - { |
|
| 135 | - return $this->parameters->current(); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - public function key() |
|
| 139 | - { |
|
| 140 | - return $this->parameters->key(); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - public function next() |
|
| 144 | - { |
|
| 145 | - return $this->parameters->next(); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - public function rewind() |
|
| 149 | - { |
|
| 150 | - return $this->parameters->rewind(); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - public function valid() |
|
| 154 | - { |
|
| 155 | - return $this->parameters->valid(); |
|
| 156 | - } |
|
| 13 | + use RefPart; |
|
| 14 | + |
|
| 15 | + /** @var ArrayList */ |
|
| 16 | + private $parameters; |
|
| 17 | + |
|
| 18 | + public function __construct($contents = []) |
|
| 19 | + { |
|
| 20 | + $this->parse($contents === null ? [] : $contents); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + private function parse($contents) |
|
| 24 | + { |
|
| 25 | + $data = CollectionUtils::toMap($contents); |
|
| 26 | + |
|
| 27 | + $this->parameters = new ArrayList(); |
|
| 28 | + $this->parseRef($data); |
|
| 29 | + |
|
| 30 | + if (!$this->hasRef()) { |
|
| 31 | + foreach ($data as $param) { |
|
| 32 | + $this->parameters->add(new Parameter($param)); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public function toArray() |
|
| 38 | + { |
|
| 39 | + if ($this->hasRef()) { |
|
| 40 | + return ['$ref' => $this->getRef()]; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + return $this->parameters->toArray(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function size() |
|
| 47 | + { |
|
| 48 | + return $this->parameters->size(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Searches whether a parameter with the given name exists. |
|
| 53 | + * |
|
| 54 | + * @param string $name |
|
| 55 | + * |
|
| 56 | + * @return bool |
|
| 57 | + */ |
|
| 58 | + public function searchByName($name) |
|
| 59 | + { |
|
| 60 | + return $this->parameters->search($name, function (Parameter $param, $name) { |
|
| 61 | + return $param->getName() == $name; |
|
| 62 | + }); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Returns parameter with the given name if it exists. |
|
| 67 | + * |
|
| 68 | + * @param string $name |
|
| 69 | + * |
|
| 70 | + * @return Parameter|void |
|
| 71 | + */ |
|
| 72 | + public function findByName($name) |
|
| 73 | + { |
|
| 74 | + foreach ($this->parameters as $param) { |
|
| 75 | + if ($param->getName() == $name) { |
|
| 76 | + return $param; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Searches for the parameter with the given name. Creates a parameter with the given name |
|
| 83 | + * if none exists. |
|
| 84 | + * |
|
| 85 | + * @param string $name |
|
| 86 | + * |
|
| 87 | + * @return Parameter |
|
| 88 | + */ |
|
| 89 | + public function getByName($name) |
|
| 90 | + { |
|
| 91 | + $param = $this->findByName($name); |
|
| 92 | + if (empty($param)) { |
|
| 93 | + $param = new Parameter(); |
|
| 94 | + $param->setName($name); |
|
| 95 | + $this->parameters->add($param); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + return $param; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Adds a parameter. |
|
| 103 | + * |
|
| 104 | + * @param Parameter $param |
|
| 105 | + */ |
|
| 106 | + public function add(Parameter $param) |
|
| 107 | + { |
|
| 108 | + $this->parameters->add($param); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Removes a parameter. |
|
| 113 | + * |
|
| 114 | + * @param Parameter $param |
|
| 115 | + */ |
|
| 116 | + public function remove(Parameter $param) |
|
| 117 | + { |
|
| 118 | + $this->parameters->remove($param); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Returns whether a given parameter exists. |
|
| 123 | + * |
|
| 124 | + * @param Parameter $param |
|
| 125 | + * |
|
| 126 | + * @return bool |
|
| 127 | + */ |
|
| 128 | + public function contains(Parameter $param) |
|
| 129 | + { |
|
| 130 | + return $this->parameters->contains($param); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + public function current() |
|
| 134 | + { |
|
| 135 | + return $this->parameters->current(); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + public function key() |
|
| 139 | + { |
|
| 140 | + return $this->parameters->key(); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + public function next() |
|
| 144 | + { |
|
| 145 | + return $this->parameters->next(); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + public function rewind() |
|
| 149 | + { |
|
| 150 | + return $this->parameters->rewind(); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + public function valid() |
|
| 154 | + { |
|
| 155 | + return $this->parameters->valid(); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function searchByName($name) |
| 59 | 59 | { |
| 60 | - return $this->parameters->search($name, function (Parameter $param, $name) { |
|
| 60 | + return $this->parameters->search($name, function(Parameter $param, $name) { |
|
| 61 | 61 | return $param->getName() == $name; |
| 62 | 62 | }); |
| 63 | 63 | } |
@@ -15,13 +15,11 @@ discard block |
||
| 15 | 15 | /** @var ArrayList */ |
| 16 | 16 | private $parameters; |
| 17 | 17 | |
| 18 | - public function __construct($contents = []) |
|
| 19 | - { |
|
| 18 | + public function __construct($contents = []) { |
|
| 20 | 19 | $this->parse($contents === null ? [] : $contents); |
| 21 | 20 | } |
| 22 | 21 | |
| 23 | - private function parse($contents) |
|
| 24 | - { |
|
| 22 | + private function parse($contents) { |
|
| 25 | 23 | $data = CollectionUtils::toMap($contents); |
| 26 | 24 | |
| 27 | 25 | $this->parameters = new ArrayList(); |
@@ -34,8 +32,7 @@ discard block |
||
| 34 | 32 | } |
| 35 | 33 | } |
| 36 | 34 | |
| 37 | - public function toArray() |
|
| 38 | - { |
|
| 35 | + public function toArray() { |
|
| 39 | 36 | if ($this->hasRef()) { |
| 40 | 37 | return ['$ref' => $this->getRef()]; |
| 41 | 38 | } |
@@ -43,8 +40,7 @@ discard block |
||
| 43 | 40 | return $this->parameters->toArray(); |
| 44 | 41 | } |
| 45 | 42 | |
| 46 | - public function size() |
|
| 47 | - { |
|
| 43 | + public function size() { |
|
| 48 | 44 | return $this->parameters->size(); |
| 49 | 45 | } |
| 50 | 46 | |
@@ -55,8 +51,7 @@ discard block |
||
| 55 | 51 | * |
| 56 | 52 | * @return bool |
| 57 | 53 | */ |
| 58 | - public function searchByName($name) |
|
| 59 | - { |
|
| 54 | + public function searchByName($name) { |
|
| 60 | 55 | return $this->parameters->search($name, function (Parameter $param, $name) { |
| 61 | 56 | return $param->getName() == $name; |
| 62 | 57 | }); |
@@ -69,8 +64,7 @@ discard block |
||
| 69 | 64 | * |
| 70 | 65 | * @return Parameter|void |
| 71 | 66 | */ |
| 72 | - public function findByName($name) |
|
| 73 | - { |
|
| 67 | + public function findByName($name) { |
|
| 74 | 68 | foreach ($this->parameters as $param) { |
| 75 | 69 | if ($param->getName() == $name) { |
| 76 | 70 | return $param; |
@@ -86,8 +80,7 @@ discard block |
||
| 86 | 80 | * |
| 87 | 81 | * @return Parameter |
| 88 | 82 | */ |
| 89 | - public function getByName($name) |
|
| 90 | - { |
|
| 83 | + public function getByName($name) { |
|
| 91 | 84 | $param = $this->findByName($name); |
| 92 | 85 | if (empty($param)) { |
| 93 | 86 | $param = new Parameter(); |
@@ -103,8 +96,7 @@ discard block |
||
| 103 | 96 | * |
| 104 | 97 | * @param Parameter $param |
| 105 | 98 | */ |
| 106 | - public function add(Parameter $param) |
|
| 107 | - { |
|
| 99 | + public function add(Parameter $param) { |
|
| 108 | 100 | $this->parameters->add($param); |
| 109 | 101 | } |
| 110 | 102 | |
@@ -113,8 +105,7 @@ discard block |
||
| 113 | 105 | * |
| 114 | 106 | * @param Parameter $param |
| 115 | 107 | */ |
| 116 | - public function remove(Parameter $param) |
|
| 117 | - { |
|
| 108 | + public function remove(Parameter $param) { |
|
| 118 | 109 | $this->parameters->remove($param); |
| 119 | 110 | } |
| 120 | 111 | |
@@ -125,33 +116,27 @@ discard block |
||
| 125 | 116 | * |
| 126 | 117 | * @return bool |
| 127 | 118 | */ |
| 128 | - public function contains(Parameter $param) |
|
| 129 | - { |
|
| 119 | + public function contains(Parameter $param) { |
|
| 130 | 120 | return $this->parameters->contains($param); |
| 131 | 121 | } |
| 132 | 122 | |
| 133 | - public function current() |
|
| 134 | - { |
|
| 123 | + public function current() { |
|
| 135 | 124 | return $this->parameters->current(); |
| 136 | 125 | } |
| 137 | 126 | |
| 138 | - public function key() |
|
| 139 | - { |
|
| 127 | + public function key() { |
|
| 140 | 128 | return $this->parameters->key(); |
| 141 | 129 | } |
| 142 | 130 | |
| 143 | - public function next() |
|
| 144 | - { |
|
| 131 | + public function next() { |
|
| 145 | 132 | return $this->parameters->next(); |
| 146 | 133 | } |
| 147 | 134 | |
| 148 | - public function rewind() |
|
| 149 | - { |
|
| 135 | + public function rewind() { |
|
| 150 | 136 | return $this->parameters->rewind(); |
| 151 | 137 | } |
| 152 | 138 | |
| 153 | - public function valid() |
|
| 154 | - { |
|
| 139 | + public function valid() { |
|
| 155 | 140 | return $this->parameters->valid(); |
| 156 | 141 | } |
| 157 | 142 | } |
@@ -9,113 +9,113 @@ |
||
| 9 | 9 | |
| 10 | 10 | class Headers implements Arrayable, \Iterator |
| 11 | 11 | { |
| 12 | - /** @var Map */ |
|
| 13 | - private $headers; |
|
| 14 | - |
|
| 15 | - public function __construct($contents = []) |
|
| 16 | - { |
|
| 17 | - $this->parse($contents === null ? [] : $contents); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - private function parse($contents) |
|
| 21 | - { |
|
| 22 | - $data = CollectionUtils::toMap($contents); |
|
| 23 | - |
|
| 24 | - // headers |
|
| 25 | - $this->headers = new Map(); |
|
| 26 | - foreach ($data as $h => $props) { |
|
| 27 | - $this->headers->set($h, new Header($h, $props)); |
|
| 28 | - } |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public function toArray() |
|
| 32 | - { |
|
| 33 | - return $this->headers->toArray(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function size() |
|
| 37 | - { |
|
| 38 | - return $this->headers->size(); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Returns whether a header with the given name exists. |
|
| 43 | - * |
|
| 44 | - * @param string $header |
|
| 45 | - * |
|
| 46 | - * @return bool |
|
| 47 | - */ |
|
| 48 | - public function has($header) |
|
| 49 | - { |
|
| 50 | - return $this->headers->has($header); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Returns whether the given header exists. |
|
| 55 | - * |
|
| 56 | - * @param Header $header |
|
| 57 | - * |
|
| 58 | - * @return bool |
|
| 59 | - */ |
|
| 60 | - public function contains(Header $header) |
|
| 61 | - { |
|
| 62 | - return $this->headers->contains($header); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Returns the header info for the given code. |
|
| 67 | - * |
|
| 68 | - * @param string $header |
|
| 69 | - * |
|
| 70 | - * @return Header |
|
| 71 | - */ |
|
| 72 | - public function get($header) |
|
| 73 | - { |
|
| 74 | - return $this->headers->get($header); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Sets the header. |
|
| 79 | - * |
|
| 80 | - * @param Header $header |
|
| 81 | - */ |
|
| 82 | - public function add(Header $header) |
|
| 83 | - { |
|
| 84 | - $this->headers->set($header->getHeader(), $header); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Removes the given header. |
|
| 89 | - * |
|
| 90 | - * @param string $header |
|
| 91 | - */ |
|
| 92 | - public function remove($header) |
|
| 93 | - { |
|
| 94 | - $this->headers->remove($header); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function current() |
|
| 98 | - { |
|
| 99 | - return $this->headers->current(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - public function key() |
|
| 103 | - { |
|
| 104 | - return $this->headers->key(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function next() |
|
| 108 | - { |
|
| 109 | - return $this->headers->next(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - public function rewind() |
|
| 113 | - { |
|
| 114 | - return $this->headers->rewind(); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - public function valid() |
|
| 118 | - { |
|
| 119 | - return $this->headers->valid(); |
|
| 120 | - } |
|
| 12 | + /** @var Map */ |
|
| 13 | + private $headers; |
|
| 14 | + |
|
| 15 | + public function __construct($contents = []) |
|
| 16 | + { |
|
| 17 | + $this->parse($contents === null ? [] : $contents); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + private function parse($contents) |
|
| 21 | + { |
|
| 22 | + $data = CollectionUtils::toMap($contents); |
|
| 23 | + |
|
| 24 | + // headers |
|
| 25 | + $this->headers = new Map(); |
|
| 26 | + foreach ($data as $h => $props) { |
|
| 27 | + $this->headers->set($h, new Header($h, $props)); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public function toArray() |
|
| 32 | + { |
|
| 33 | + return $this->headers->toArray(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function size() |
|
| 37 | + { |
|
| 38 | + return $this->headers->size(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Returns whether a header with the given name exists. |
|
| 43 | + * |
|
| 44 | + * @param string $header |
|
| 45 | + * |
|
| 46 | + * @return bool |
|
| 47 | + */ |
|
| 48 | + public function has($header) |
|
| 49 | + { |
|
| 50 | + return $this->headers->has($header); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Returns whether the given header exists. |
|
| 55 | + * |
|
| 56 | + * @param Header $header |
|
| 57 | + * |
|
| 58 | + * @return bool |
|
| 59 | + */ |
|
| 60 | + public function contains(Header $header) |
|
| 61 | + { |
|
| 62 | + return $this->headers->contains($header); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Returns the header info for the given code. |
|
| 67 | + * |
|
| 68 | + * @param string $header |
|
| 69 | + * |
|
| 70 | + * @return Header |
|
| 71 | + */ |
|
| 72 | + public function get($header) |
|
| 73 | + { |
|
| 74 | + return $this->headers->get($header); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Sets the header. |
|
| 79 | + * |
|
| 80 | + * @param Header $header |
|
| 81 | + */ |
|
| 82 | + public function add(Header $header) |
|
| 83 | + { |
|
| 84 | + $this->headers->set($header->getHeader(), $header); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Removes the given header. |
|
| 89 | + * |
|
| 90 | + * @param string $header |
|
| 91 | + */ |
|
| 92 | + public function remove($header) |
|
| 93 | + { |
|
| 94 | + $this->headers->remove($header); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function current() |
|
| 98 | + { |
|
| 99 | + return $this->headers->current(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + public function key() |
|
| 103 | + { |
|
| 104 | + return $this->headers->key(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function next() |
|
| 108 | + { |
|
| 109 | + return $this->headers->next(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + public function rewind() |
|
| 113 | + { |
|
| 114 | + return $this->headers->rewind(); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + public function valid() |
|
| 118 | + { |
|
| 119 | + return $this->headers->valid(); |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -12,13 +12,11 @@ discard block |
||
| 12 | 12 | /** @var Map */ |
| 13 | 13 | private $headers; |
| 14 | 14 | |
| 15 | - public function __construct($contents = []) |
|
| 16 | - { |
|
| 15 | + public function __construct($contents = []) { |
|
| 17 | 16 | $this->parse($contents === null ? [] : $contents); |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | - private function parse($contents) |
|
| 21 | - { |
|
| 19 | + private function parse($contents) { |
|
| 22 | 20 | $data = CollectionUtils::toMap($contents); |
| 23 | 21 | |
| 24 | 22 | // headers |
@@ -28,13 +26,11 @@ discard block |
||
| 28 | 26 | } |
| 29 | 27 | } |
| 30 | 28 | |
| 31 | - public function toArray() |
|
| 32 | - { |
|
| 29 | + public function toArray() { |
|
| 33 | 30 | return $this->headers->toArray(); |
| 34 | 31 | } |
| 35 | 32 | |
| 36 | - public function size() |
|
| 37 | - { |
|
| 33 | + public function size() { |
|
| 38 | 34 | return $this->headers->size(); |
| 39 | 35 | } |
| 40 | 36 | |
@@ -45,8 +41,7 @@ discard block |
||
| 45 | 41 | * |
| 46 | 42 | * @return bool |
| 47 | 43 | */ |
| 48 | - public function has($header) |
|
| 49 | - { |
|
| 44 | + public function has($header) { |
|
| 50 | 45 | return $this->headers->has($header); |
| 51 | 46 | } |
| 52 | 47 | |
@@ -57,8 +52,7 @@ discard block |
||
| 57 | 52 | * |
| 58 | 53 | * @return bool |
| 59 | 54 | */ |
| 60 | - public function contains(Header $header) |
|
| 61 | - { |
|
| 55 | + public function contains(Header $header) { |
|
| 62 | 56 | return $this->headers->contains($header); |
| 63 | 57 | } |
| 64 | 58 | |
@@ -69,8 +63,7 @@ discard block |
||
| 69 | 63 | * |
| 70 | 64 | * @return Header |
| 71 | 65 | */ |
| 72 | - public function get($header) |
|
| 73 | - { |
|
| 66 | + public function get($header) { |
|
| 74 | 67 | return $this->headers->get($header); |
| 75 | 68 | } |
| 76 | 69 | |
@@ -79,8 +72,7 @@ discard block |
||
| 79 | 72 | * |
| 80 | 73 | * @param Header $header |
| 81 | 74 | */ |
| 82 | - public function add(Header $header) |
|
| 83 | - { |
|
| 75 | + public function add(Header $header) { |
|
| 84 | 76 | $this->headers->set($header->getHeader(), $header); |
| 85 | 77 | } |
| 86 | 78 | |
@@ -89,33 +81,27 @@ discard block |
||
| 89 | 81 | * |
| 90 | 82 | * @param string $header |
| 91 | 83 | */ |
| 92 | - public function remove($header) |
|
| 93 | - { |
|
| 84 | + public function remove($header) { |
|
| 94 | 85 | $this->headers->remove($header); |
| 95 | 86 | } |
| 96 | 87 | |
| 97 | - public function current() |
|
| 98 | - { |
|
| 88 | + public function current() { |
|
| 99 | 89 | return $this->headers->current(); |
| 100 | 90 | } |
| 101 | 91 | |
| 102 | - public function key() |
|
| 103 | - { |
|
| 92 | + public function key() { |
|
| 104 | 93 | return $this->headers->key(); |
| 105 | 94 | } |
| 106 | 95 | |
| 107 | - public function next() |
|
| 108 | - { |
|
| 96 | + public function next() { |
|
| 109 | 97 | return $this->headers->next(); |
| 110 | 98 | } |
| 111 | 99 | |
| 112 | - public function rewind() |
|
| 113 | - { |
|
| 100 | + public function rewind() { |
|
| 114 | 101 | return $this->headers->rewind(); |
| 115 | 102 | } |
| 116 | 103 | |
| 117 | - public function valid() |
|
| 118 | - { |
|
| 104 | + public function valid() { |
|
| 119 | 105 | return $this->headers->valid(); |
| 120 | 106 | } |
| 121 | 107 | } |
@@ -11,132 +11,132 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Paths implements Arrayable, \Iterator |
| 13 | 13 | { |
| 14 | - use ExtensionPart; |
|
| 15 | - |
|
| 16 | - /** @var Map */ |
|
| 17 | - private $paths; |
|
| 18 | - |
|
| 19 | - public function __construct($contents = []) |
|
| 20 | - { |
|
| 21 | - $this->parse($contents === null ? [] : $contents); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - private function parse($contents) |
|
| 25 | - { |
|
| 26 | - $data = CollectionUtils::toMap($contents); |
|
| 27 | - |
|
| 28 | - // paths |
|
| 29 | - $this->paths = new Map(); |
|
| 30 | - foreach ($data as $p => $path) { |
|
| 31 | - if (!Text::create($p)->startsWith('x-')) { |
|
| 32 | - $this->paths->set($p, new Path($p, $path)); |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - // extensions |
|
| 37 | - $this->parseExtensions($data); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public function toArray() |
|
| 41 | - { |
|
| 42 | - $paths = clone $this->paths; |
|
| 14 | + use ExtensionPart; |
|
| 15 | + |
|
| 16 | + /** @var Map */ |
|
| 17 | + private $paths; |
|
| 18 | + |
|
| 19 | + public function __construct($contents = []) |
|
| 20 | + { |
|
| 21 | + $this->parse($contents === null ? [] : $contents); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + private function parse($contents) |
|
| 25 | + { |
|
| 26 | + $data = CollectionUtils::toMap($contents); |
|
| 27 | + |
|
| 28 | + // paths |
|
| 29 | + $this->paths = new Map(); |
|
| 30 | + foreach ($data as $p => $path) { |
|
| 31 | + if (!Text::create($p)->startsWith('x-')) { |
|
| 32 | + $this->paths->set($p, new Path($p, $path)); |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + // extensions |
|
| 37 | + $this->parseExtensions($data); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public function toArray() |
|
| 41 | + { |
|
| 42 | + $paths = clone $this->paths; |
|
| 43 | 43 | // $paths->setAll($this->getExtensions()); |
| 44 | - return $paths->toArray(); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function size() |
|
| 48 | - { |
|
| 49 | - return $this->paths->size(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Returns whether a path with the given name exists. |
|
| 54 | - * |
|
| 55 | - * @param string $path |
|
| 56 | - * |
|
| 57 | - * @return bool |
|
| 58 | - */ |
|
| 59 | - public function has($path) |
|
| 60 | - { |
|
| 61 | - return $this->paths->has($path); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Returns whether the given path exists. |
|
| 66 | - * |
|
| 67 | - * @param Path $path |
|
| 68 | - * |
|
| 69 | - * @return bool |
|
| 70 | - */ |
|
| 71 | - public function contains(Path $path) |
|
| 72 | - { |
|
| 73 | - return $this->paths->contains($path); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Returns the path info for the given path. |
|
| 78 | - * |
|
| 79 | - * @param string $path |
|
| 80 | - * |
|
| 81 | - * @return Path |
|
| 82 | - */ |
|
| 83 | - public function get($path) |
|
| 84 | - { |
|
| 85 | - if (!$this->paths->has($path)) { |
|
| 86 | - $this->paths->set($path, new Path($path)); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - return $this->paths->get($path); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Sets the path. |
|
| 94 | - * |
|
| 95 | - * @param Path $path |
|
| 96 | - * |
|
| 97 | - * @return $this |
|
| 98 | - */ |
|
| 99 | - public function add(Path $path) |
|
| 100 | - { |
|
| 101 | - $this->paths->set($path->getPath(), $path); |
|
| 102 | - |
|
| 103 | - return $this; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Removes the given path. |
|
| 108 | - * |
|
| 109 | - * @param string $path |
|
| 110 | - */ |
|
| 111 | - public function remove($path) |
|
| 112 | - { |
|
| 113 | - $this->paths->remove($path); |
|
| 114 | - |
|
| 115 | - return $this; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public function current() |
|
| 119 | - { |
|
| 120 | - return $this->paths->current(); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - public function key() |
|
| 124 | - { |
|
| 125 | - return $this->paths->key(); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - public function next() |
|
| 129 | - { |
|
| 130 | - return $this->paths->next(); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - public function rewind() |
|
| 134 | - { |
|
| 135 | - return $this->paths->rewind(); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - public function valid() |
|
| 139 | - { |
|
| 140 | - return $this->paths->valid(); |
|
| 141 | - } |
|
| 44 | + return $paths->toArray(); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function size() |
|
| 48 | + { |
|
| 49 | + return $this->paths->size(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Returns whether a path with the given name exists. |
|
| 54 | + * |
|
| 55 | + * @param string $path |
|
| 56 | + * |
|
| 57 | + * @return bool |
|
| 58 | + */ |
|
| 59 | + public function has($path) |
|
| 60 | + { |
|
| 61 | + return $this->paths->has($path); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Returns whether the given path exists. |
|
| 66 | + * |
|
| 67 | + * @param Path $path |
|
| 68 | + * |
|
| 69 | + * @return bool |
|
| 70 | + */ |
|
| 71 | + public function contains(Path $path) |
|
| 72 | + { |
|
| 73 | + return $this->paths->contains($path); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Returns the path info for the given path. |
|
| 78 | + * |
|
| 79 | + * @param string $path |
|
| 80 | + * |
|
| 81 | + * @return Path |
|
| 82 | + */ |
|
| 83 | + public function get($path) |
|
| 84 | + { |
|
| 85 | + if (!$this->paths->has($path)) { |
|
| 86 | + $this->paths->set($path, new Path($path)); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + return $this->paths->get($path); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Sets the path. |
|
| 94 | + * |
|
| 95 | + * @param Path $path |
|
| 96 | + * |
|
| 97 | + * @return $this |
|
| 98 | + */ |
|
| 99 | + public function add(Path $path) |
|
| 100 | + { |
|
| 101 | + $this->paths->set($path->getPath(), $path); |
|
| 102 | + |
|
| 103 | + return $this; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Removes the given path. |
|
| 108 | + * |
|
| 109 | + * @param string $path |
|
| 110 | + */ |
|
| 111 | + public function remove($path) |
|
| 112 | + { |
|
| 113 | + $this->paths->remove($path); |
|
| 114 | + |
|
| 115 | + return $this; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public function current() |
|
| 119 | + { |
|
| 120 | + return $this->paths->current(); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + public function key() |
|
| 124 | + { |
|
| 125 | + return $this->paths->key(); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + public function next() |
|
| 129 | + { |
|
| 130 | + return $this->paths->next(); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + public function rewind() |
|
| 134 | + { |
|
| 135 | + return $this->paths->rewind(); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + public function valid() |
|
| 139 | + { |
|
| 140 | + return $this->paths->valid(); |
|
| 141 | + } |
|
| 142 | 142 | } |
@@ -16,13 +16,11 @@ discard block |
||
| 16 | 16 | /** @var Map */ |
| 17 | 17 | private $paths; |
| 18 | 18 | |
| 19 | - public function __construct($contents = []) |
|
| 20 | - { |
|
| 19 | + public function __construct($contents = []) { |
|
| 21 | 20 | $this->parse($contents === null ? [] : $contents); |
| 22 | 21 | } |
| 23 | 22 | |
| 24 | - private function parse($contents) |
|
| 25 | - { |
|
| 23 | + private function parse($contents) { |
|
| 26 | 24 | $data = CollectionUtils::toMap($contents); |
| 27 | 25 | |
| 28 | 26 | // paths |
@@ -37,15 +35,13 @@ discard block |
||
| 37 | 35 | $this->parseExtensions($data); |
| 38 | 36 | } |
| 39 | 37 | |
| 40 | - public function toArray() |
|
| 41 | - { |
|
| 38 | + public function toArray() { |
|
| 42 | 39 | $paths = clone $this->paths; |
| 43 | 40 | // $paths->setAll($this->getExtensions()); |
| 44 | 41 | return $paths->toArray(); |
| 45 | 42 | } |
| 46 | 43 | |
| 47 | - public function size() |
|
| 48 | - { |
|
| 44 | + public function size() { |
|
| 49 | 45 | return $this->paths->size(); |
| 50 | 46 | } |
| 51 | 47 | |
@@ -56,8 +52,7 @@ discard block |
||
| 56 | 52 | * |
| 57 | 53 | * @return bool |
| 58 | 54 | */ |
| 59 | - public function has($path) |
|
| 60 | - { |
|
| 55 | + public function has($path) { |
|
| 61 | 56 | return $this->paths->has($path); |
| 62 | 57 | } |
| 63 | 58 | |
@@ -68,8 +63,7 @@ discard block |
||
| 68 | 63 | * |
| 69 | 64 | * @return bool |
| 70 | 65 | */ |
| 71 | - public function contains(Path $path) |
|
| 72 | - { |
|
| 66 | + public function contains(Path $path) { |
|
| 73 | 67 | return $this->paths->contains($path); |
| 74 | 68 | } |
| 75 | 69 | |
@@ -80,8 +74,7 @@ discard block |
||
| 80 | 74 | * |
| 81 | 75 | * @return Path |
| 82 | 76 | */ |
| 83 | - public function get($path) |
|
| 84 | - { |
|
| 77 | + public function get($path) { |
|
| 85 | 78 | if (!$this->paths->has($path)) { |
| 86 | 79 | $this->paths->set($path, new Path($path)); |
| 87 | 80 | } |
@@ -96,8 +89,7 @@ discard block |
||
| 96 | 89 | * |
| 97 | 90 | * @return $this |
| 98 | 91 | */ |
| 99 | - public function add(Path $path) |
|
| 100 | - { |
|
| 92 | + public function add(Path $path) { |
|
| 101 | 93 | $this->paths->set($path->getPath(), $path); |
| 102 | 94 | |
| 103 | 95 | return $this; |
@@ -108,35 +100,29 @@ discard block |
||
| 108 | 100 | * |
| 109 | 101 | * @param string $path |
| 110 | 102 | */ |
| 111 | - public function remove($path) |
|
| 112 | - { |
|
| 103 | + public function remove($path) { |
|
| 113 | 104 | $this->paths->remove($path); |
| 114 | 105 | |
| 115 | 106 | return $this; |
| 116 | 107 | } |
| 117 | 108 | |
| 118 | - public function current() |
|
| 119 | - { |
|
| 109 | + public function current() { |
|
| 120 | 110 | return $this->paths->current(); |
| 121 | 111 | } |
| 122 | 112 | |
| 123 | - public function key() |
|
| 124 | - { |
|
| 113 | + public function key() { |
|
| 125 | 114 | return $this->paths->key(); |
| 126 | 115 | } |
| 127 | 116 | |
| 128 | - public function next() |
|
| 129 | - { |
|
| 117 | + public function next() { |
|
| 130 | 118 | return $this->paths->next(); |
| 131 | 119 | } |
| 132 | 120 | |
| 133 | - public function rewind() |
|
| 134 | - { |
|
| 121 | + public function rewind() { |
|
| 135 | 122 | return $this->paths->rewind(); |
| 136 | 123 | } |
| 137 | 124 | |
| 138 | - public function valid() |
|
| 139 | - { |
|
| 125 | + public function valid() { |
|
| 140 | 126 | return $this->paths->valid(); |
| 141 | 127 | } |
| 142 | 128 | } |
@@ -10,27 +10,27 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ExternalDocs extends AbstractModel implements Arrayable |
| 12 | 12 | { |
| 13 | - use DescriptionPart; |
|
| 14 | - use UrlPart; |
|
| 15 | - use ExtensionPart; |
|
| 13 | + use DescriptionPart; |
|
| 14 | + use UrlPart; |
|
| 15 | + use ExtensionPart; |
|
| 16 | 16 | |
| 17 | - public function __construct($contents = []) |
|
| 18 | - { |
|
| 19 | - $this->parse($contents); |
|
| 20 | - } |
|
| 17 | + public function __construct($contents = []) |
|
| 18 | + { |
|
| 19 | + $this->parse($contents); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - private function parse($contents = []) |
|
| 23 | - { |
|
| 24 | - $data = CollectionUtils::toMap($contents); |
|
| 22 | + private function parse($contents = []) |
|
| 23 | + { |
|
| 24 | + $data = CollectionUtils::toMap($contents); |
|
| 25 | 25 | |
| 26 | - // parts |
|
| 27 | - $this->parseDescription($data); |
|
| 28 | - $this->parseUrl($data); |
|
| 29 | - $this->parseExtensions($data); |
|
| 30 | - } |
|
| 26 | + // parts |
|
| 27 | + $this->parseDescription($data); |
|
| 28 | + $this->parseUrl($data); |
|
| 29 | + $this->parseExtensions($data); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function toArray() |
|
| 33 | - { |
|
| 34 | - return $this->export('description', 'url'); |
|
| 35 | - } |
|
| 32 | + public function toArray() |
|
| 33 | + { |
|
| 34 | + return $this->export('description', 'url'); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -8,19 +8,16 @@ discard block |
||
| 8 | 8 | use gossi\swagger\parts\DescriptionPart; |
| 9 | 9 | use gossi\swagger\parts\UrlPart; |
| 10 | 10 | |
| 11 | -class ExternalDocs extends AbstractModel implements Arrayable |
|
| 12 | -{ |
|
| 11 | +class ExternalDocs extends AbstractModel implements Arrayable { |
|
| 13 | 12 | use DescriptionPart; |
| 14 | 13 | use UrlPart; |
| 15 | 14 | use ExtensionPart; |
| 16 | 15 | |
| 17 | - public function __construct($contents = []) |
|
| 18 | - { |
|
| 16 | + public function __construct($contents = []) { |
|
| 19 | 17 | $this->parse($contents); |
| 20 | 18 | } |
| 21 | 19 | |
| 22 | - private function parse($contents = []) |
|
| 23 | - { |
|
| 20 | + private function parse($contents = []) { |
|
| 24 | 21 | $data = CollectionUtils::toMap($contents); |
| 25 | 22 | |
| 26 | 23 | // parts |
@@ -29,8 +26,7 @@ discard block |
||
| 29 | 26 | $this->parseExtensions($data); |
| 30 | 27 | } |
| 31 | 28 | |
| 32 | - public function toArray() |
|
| 33 | - { |
|
| 29 | + public function toArray() { |
|
| 34 | 30 | return $this->export('description', 'url'); |
| 35 | 31 | } |
| 36 | 32 | } |