BaseCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 19
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadFromServerRequest() 0 6 2
A commandName() 0 6 1
1
<?php
2
/**
3
 * HiAPI Yii2 base project for building API
4
 *
5
 * @link      https://github.com/hiqdev/hiapi
6
 * @package   hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiapi\commands;
12
13
use Psr\Http\Message\ServerRequestInterface;
14
15
abstract class BaseCommand extends \yii\base\Model
16
{
17
    public function loadFromServerRequest(ServerRequestInterface $request): bool
18
    {
19
        $data = $request->getParsedBody() ?: $request->getQueryParams();
20
21
        return $this->load($data, '');
22
    }
23
24
    /**
25
     * XXX doubt it should be needed!
26
     */
27
    public function commandName(): string
28
    {
29
        return strtr((new \ReflectionObject($this))->getShortName(), [
30
            'Command' => '',
31
        ]);
32
    }
33
}
34