Completed
Pull Request — master (#1)
by Angel
07:01
created

SectionField::getLinks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
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
11
/**
12
 * ROA contract handling form SectionField records.
13
 */
14
class SectionField extends base\SectionField implements Contract
15
{
16
    use ContractTrait {
17
        getLinks as getContractLinks;
18
    }
19
20
    /**
21
     * @inheritdoc
22
     */
23
    protected $sectionClass = Section::class;
24
25
    /**
26
     * @inheritdoc
27
     */
28
    protected $fieldClass = Field::class;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    protected $solicitudeValueClass = SolicitudeValue::class;
34
35
    /**
36
     * @inheritdoc
37
     */
38 4
    public function getLinks()
39
    {
40 4
        $selfLink = $this->getSelfLink();
0 ignored issues
show
Unused Code introduced by
The assignment to $selfLink is dead and can be removed.
Loading history...
41
42 4
        return array_merge($this->getContractLinks(), [
43 4
            'field' => $this->field->getSelfLink(),
0 ignored issues
show
Bug introduced by
The method getSelfLink() does not exist on roaresearch\yii2\formgenerator\models\Field. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

43
            'field' => $this->field->/** @scrutinizer ignore-call */ getSelfLink(),
Loading history...
44
        ]);
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50 5
    protected function slugBehaviorConfig(): array
51
    {
52
        return [
53 5
            'idAttribute' => 'field_id',
54
            'resourceName' => 'field',
55
            'parentSlugRelation' => 'section',
56
        ];
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62 4
    public function extraFields()
63
    {
64 4
        return ['field', 'section', 'solicitudeValuesDetail'];
65
    }
66
}
67