Completed
Push — master ( 23dba2...2f50c1 )
by Andrii
13:23
created

GetInfoCommand::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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 hiqdev\DataMapper\Query\Specification;
14
use hiapi\validators\RefValidator;
15
16
abstract class GetInfoCommand extends EntityCommand
17
{
18
    public $id;
19
20
    public $with;
21
22
    public function getId()
23
    {
24
        return $this->id;
25
    }
26
27
    public function rules()
28
    {
29
        return [
30
            ['id', 'integer', 'min' => 1],
31
            ['id', 'required'],
32
33
            ['with', 'each', 'rule' => [RefValidator::class]],
34
        ];
35
    }
36
37
    public function getSpecification(): Specification
38
    {
39
        $spec = new Specification();
40
        $spec->where = ['id' => $this->getId()];
41
        $spec->with = $this->with;
42
43
        return $spec;
44
    }
45
}
46