FieldRuleProperty::extraFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\formgenerator\roa\models;
4
5
use roaresearch\yii2\formgenerator\models as base;
6
use roaresearch\yii2\roa\hal\{Contract, ContractTrait};
7
use yii\{helpers\Url, web\Link, web\NotFoundHttpException};
8
9
/**
10
 * ROA contract handling FieldRuleProperty records.
11
 */
12
class FieldRuleProperty extends base\FieldRuleProperty implements Contract
13
{
14
    use ContractTrait {
15
        getLinks as getContractLinks;
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    protected $ruleClass = FieldRule::class;
22
23
    /**
24
     * @inheritdoc
25
     */
26 4
    public function getLinks()
27
    {
28 4
        $selfLink = $this->getSelfLink();
29
30 4
        return array_merge($this->getContractLinks(), [
31 4
            'properties' => $selfLink . '/property',
32
            'curies' => [
33 4
                new Link([
34 4
                    'name' => 'nestable',
35 4
                    'href' => Url::to($selfLink, ['expand' => '{rel}']),
0 ignored issues
show
Bug introduced by
array('expand' => '{rel}') of type array<string,string> is incompatible with the type boolean|string expected by parameter $scheme of yii\helpers\BaseUrl::to(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
                    'href' => Url::to($selfLink, /** @scrutinizer ignore-type */ ['expand' => '{rel}']),
Loading history...
36 4
                    'title' => 'Embeddable and Nestable related resources.',
37
                ]),
38
            ],
39 4
            'nestable:rule' => 'rule',
40
        ]);
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 5
    protected function slugBehaviorConfig(): array
47
    {
48
        return [
49 5
            'idAttribute' => 'property',
50
            'resourceName' => 'property',
51
            'parentSlugRelation' => 'rule',
52
        ];
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58 4
    public function extraFields()
59
    {
60 4
        return ['rule'];
61
    }
62
}
63