Completed
Push — master ( 2cc7d9...dc32a9 )
by Yaroslav
04:50
created

GenerateCommentsDocData::handle()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 4
nc 3
nop 0
1
<?php
2
3
namespace App\Console\Commands\Cache;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Str;
7
use ReflectionClass;
8
9
class GenerateCommentsDocData extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'l-api-response:generate-doc {class="\HttpStatusCodes\RFCStatusCodes"}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Generate Comments Doc Data';
24
25
    /**
26
     * Create a new command instance.
27
     *
28
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return void
39
     * @throws \ReflectionException
40
     */
41
    public function handle()
42
    {
43
        $rc = new ReflectionClass($this->argument('class'));
44
        foreach ($rc->getConstants() as $constantName => $code) {
45
            if (is_int($code) && substr($constantName, 0, 5) === 'HTTP_') {
46
                $funcName = substr($constantName, 5);
47
                $funcName = Str::camel(Str::lower($funcName));
48
                $this->info("@method JsonResponse $funcName(array \$data = [], string \$message = null)");
49
            }
50
        }
51
    }
52
}
53