Curies   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 47
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCuriesLinks() 0 22 4
1
<?php
2
3
namespace roaresearch\yii2\roa\behaviors;
4
5
use yii\{helpers\Url, web\Link};
6
7
/**
8
 * Behavior to autogenerate curies links.
9
 *
10
 * @author Angel (Faryshta) Guevara <[email protected]>
11
 */
12
class Curies extends \yii\base\Behavior
13
{
14
    /**
15
     * @var Link[] The curies links. Autogenerated links will be stored here.
16
     */
17
    public array $curiesLinks = [];
18
19
    /**
20
     * @var ?string name of the autogenerated expand curie. Set `null` if you
21
     * don't want to autogenerate expand curie.
22
     */
23
    public ?string $expandCurieName = 'expand';
24
25
    /**
26
     * @var array the configuration used to generate the expand curie.
27
     */
28
    public array $expandCurieLink = [
29
        'title' => 'Embeddable related resources.',
30
    ];
31
32
    /**
33
     * Return all the curies and related links.
34
     *
35
     * @return array the configured and autogenerated curies and related links.
36
     */
37 9
    public function getCuriesLinks(): array
38
    {
39 9
        if ($this->expandCurieName) {
40 9
            $this->curiesLinks['curies'][] = new Link(array_merge(
41 9
                $this->expandCurieLink,
42
                [
43 9
                    'name' => $this->expandCurieName,
44 9
                    'href' => $this->owner->getSelfLink()
0 ignored issues
show
Bug introduced by
The method getSelfLink() does not exist on null. ( Ignorable by Annotation )

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

44
                    'href' => $this->owner->/** @scrutinizer ignore-call */ getSelfLink()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45 9
                        . "?{$this->expandCurieName}={rel}",
46
                ]
47
            ));
48
49 9
            foreach ($this->owner->extraFields() as $field => $value) {
50 9
                if (is_int($field)) {
51 9
                    $field = $value;
52
                }
53
54 9
                $this->curiesLinks["{$this->expandCurieName}:$field"] = $field;
55
            }
56
        }
57
58 9
        return $this->curiesLinks;
59
    }
60
}
61