GenerateCommentsDocData::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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
    public function __construct()
29
    {
30
        parent::__construct();
31
    }
32
33
    /**
34
     * Execute the console command.
35
     *
36
     * @return void
37
     * @throws \ReflectionException
38
     */
39
    public function handle()
40
    {
41
        $rc = new ReflectionClass($this->argument('class'));
42
        foreach ($rc->getConstants() as $constantName => $code) {
43
            if (is_int($code) && substr($constantName, 0, 5) === 'HTTP_') {
44
                $funcName = substr($constantName, 5);
45
                $funcName = Str::camel(Str::lower($funcName));
46
                $this->info("@method JsonResponse $funcName(array \$data = [], string \$message = null)");
47
            }
48
        }
49
    }
50
}
51