Completed
Push — master ( 857ea9...f24760 )
by Fran
03:35
created

Api::createApiDocs()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 9.4285
ccs 0
cts 9
cp 0
crap 12
1
<?php
2
    namespace PSFS\controller;
3
4
    use PSFS\base\types\Controller;
5
6
    /**
7
     * Class Api
8
     * @package PSFS\controller
9
     */
10
    class Api extends Controller
11
    {
12
        const DOMAIN = 'ROOT';
13
14
        /**
15
         * @Inyectable
16
         * @var \PSFS\Services\DocumentorService srv
17
         */
18
        protected $srv;
19
20
        /**
21
         * @GET
22
         * @route /api/__doc/{type}
23
         *
24
         * @param string $type
25
         *
26
         * @return string JSON
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
27
         */
28
        public function createApiDocs($type = 'swagger')
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
        {
30
            $doc = $endpoints = [];
31
            $modules = $this->srv->getModules();
32
            if (count($modules)) {
33
                foreach ($modules as $module) {
34
                    $endpoints = array_merge($doc, $this->srv->extractApiEndpoints($module));
35
                }
36
            }
37
38
            return $this->json($endpoints, 200);
39
        }
40
    }