Test Failed
Pull Request — master (#1)
by Carlos
03:47
created

FieldRuleProperty::slugBehaviorConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
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;
7
use roaresearch\yii2\roa\hal\ContractTrait;
8
use yii\helpers\Url;
9
use yii\web\Link;
10
use yii\web\NotFoundHttpException;
11
12
/**
13
 * ROA contract handling FieldRuleProperty records.
14
 */
15
class FieldRuleProperty extends base\FieldRuleProperty implements Contract
16
{
17
    use ContractTrait {
18
        getLinks as getContractLinks;
19
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24
    protected $ruleClass = FieldRule::class;
25
26
    /**
27
     * @inheritdoc
28
     */
29 4
    public function getLinks()
30
    {
31 4
        $selfLink = $this->getSelfLink();
32
33 4
        return array_merge($this->getContractLinks(), [
34 4
            'properties' => $selfLink . '/property',
35
            'curies' => [
36 4
                new Link([
37 4
                    'name' => 'nestable',
38 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

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