|
1 | 1 | <?php namespace Gitlab\Api; |
2 | 2 |
|
| 3 | +use Symfony\Component\OptionsResolver\Options; |
3 | 4 | use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; |
4 | 5 | use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; |
5 | 6 | use Symfony\Component\OptionsResolver\OptionsResolver; |
@@ -33,7 +34,7 @@ class Projects extends AbstractApi |
33 | 34 | public function all(array $parameters = []) |
34 | 35 | { |
35 | 36 | $resolver = $this->createOptionsResolver(); |
36 | | - $booleanNormalizer = function ($value) { |
| 37 | + $booleanNormalizer = function (Options $resolver, $value) { |
37 | 38 | return $value ? 'true' : 'false'; |
38 | 39 | }; |
39 | 40 | $resolver->setDefined('archived') |
@@ -84,11 +85,28 @@ public function all(array $parameters = []) |
84 | 85 |
|
85 | 86 | /** |
86 | 87 | * @param int $project_id |
| 88 | + * @param array $parameters { |
| 89 | + * |
| 90 | + * @var bool $statistics Include project statistics. |
| 91 | + * @var bool $with_custom_attributes Include project custom attributes. |
| 92 | + * } |
87 | 93 | * @return mixed |
88 | 94 | */ |
89 | | - public function show($project_id) |
| 95 | + public function show($project_id, array $parameters = []) |
90 | 96 | { |
91 | | - return $this->get('projects/'.$this->encodePath($project_id)); |
| 97 | + $resolver = $this->createOptionsResolver(); |
| 98 | + $booleanNormalizer = function (Options $resolver, $value) { |
| 99 | + return $value ? true : false; |
| 100 | + }; |
| 101 | + $resolver->setDefined('statistics') |
| 102 | + ->setAllowedTypes('statistics', 'bool') |
| 103 | + ->setNormalizer('statistics', $booleanNormalizer) |
| 104 | + ; |
| 105 | + $resolver->setDefined('with_custom_attributes') |
| 106 | + ->setAllowedTypes('with_custom_attributes', 'bool') |
| 107 | + ->setNormalizer('with_custom_attributes', $booleanNormalizer) |
| 108 | + ; |
| 109 | + return $this->get('projects/'.$this->encodePath($project_id), $resolver->resolve($parameters)); |
92 | 110 | } |
93 | 111 |
|
94 | 112 | /** |
@@ -171,7 +189,7 @@ public function unarchive($project_id) |
171 | 189 | public function pipelines($project_id, array $parameters = []) |
172 | 190 | { |
173 | 191 | $resolver = $this->createOptionsResolver(); |
174 | | - $booleanNormalizer = function ($value) { |
| 192 | + $booleanNormalizer = function (Options $resolver, $value) { |
175 | 193 | return $value ? 'true' : 'false'; |
176 | 194 | }; |
177 | 195 |
|
@@ -241,14 +259,33 @@ public function cancelPipeline($project_id, $pipeline_id) |
241 | 259 |
|
242 | 260 | /** |
243 | 261 | * @param int $project_id |
244 | | - * @param string $username_query |
| 262 | + * @param array $parameters ( |
| 263 | + * |
| 264 | + * @var string $query The query you want to search members for. |
| 265 | + * ) |
| 266 | + * |
| 267 | + * @throws MissingOptionsException If a required option is not provided |
| 268 | + * |
245 | 269 | * @return mixed |
246 | 270 | */ |
247 | | - public function members($project_id, $username_query = null) |
| 271 | + public function members($project_id, $parameters = []) |
248 | 272 | { |
249 | | - return $this->get($this->getProjectPath($project_id, 'members'), array( |
250 | | - 'query' => $username_query |
251 | | - )); |
| 273 | + if (!is_array($parameters)) { |
| 274 | + @trigger_error("Deprecated: String parameter of the members() function is deprecated.", E_USER_NOTICE); |
| 275 | + $username_query = $parameters; |
| 276 | + $parameters = array(); |
| 277 | + if (!empty($username_query)) { |
| 278 | + $parameters['query'] = $username_query; |
| 279 | + } |
| 280 | + } |
| 281 | + |
| 282 | + $resolver = $this->createOptionsResolver(); |
| 283 | + |
| 284 | + $resolver->setDefined('query') |
| 285 | + ->setAllowedTypes('query', 'string') |
| 286 | + ; |
| 287 | + |
| 288 | + return $this->get($this->getProjectPath($project_id, 'members'), $resolver->resolve($parameters)); |
252 | 289 | } |
253 | 290 |
|
254 | 291 | /** |
@@ -430,7 +467,7 @@ public function enableDeployKey($project_id, $key_id) |
430 | 467 | public function events($project_id, array $parameters = []) |
431 | 468 | { |
432 | 469 | $resolver = $this->createOptionsResolver(); |
433 | | - $datetimeNormalizer = function (\DateTimeInterface $value) { |
| 470 | + $datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value) { |
434 | 471 | return $value->format('Y-m-d'); |
435 | 472 | }; |
436 | 473 |
|
@@ -495,6 +532,17 @@ public function removeLabel($project_id, $name) |
495 | 532 | )); |
496 | 533 | } |
497 | 534 |
|
| 535 | + /** |
| 536 | + * Get languages used in a project with percentage value. |
| 537 | + * |
| 538 | + * @param int $project_id |
| 539 | + * @return mixed |
| 540 | + */ |
| 541 | + public function languages($project_id) |
| 542 | + { |
| 543 | + return $this->get($this->getProjectPath($project_id, 'languages')); |
| 544 | + } |
| 545 | + |
498 | 546 | /** |
499 | 547 | * @param int $project_id |
500 | 548 | * @param array $params ( |
@@ -555,11 +603,15 @@ public function removeService($project_id, $service_name) |
555 | 603 |
|
556 | 604 | /** |
557 | 605 | * @param int $project_id |
| 606 | + * @param array $parameters |
| 607 | + * |
558 | 608 | * @return mixed |
559 | 609 | */ |
560 | | - public function variables($project_id) |
| 610 | + public function variables($project_id, array $parameters = []) |
561 | 611 | { |
562 | | - return $this->get($this->getProjectPath($project_id, 'variables')); |
| 612 | + $resolver = $this->createOptionsResolver(); |
| 613 | + |
| 614 | + return $this->get($this->getProjectPath($project_id, 'variables'), $resolver->resolve($parameters)); |
563 | 615 | } |
564 | 616 |
|
565 | 617 | /** |
|
0 commit comments