GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Asset   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 20
c 1
b 1
f 0
dl 0
loc 89
rs 10
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetSet() 0 9 2
A import() 0 9 3
A __construct() 0 3 1
A createElement() 0 12 2
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Html\Dom\Lists;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Html\Document;
19
use O2System\Html\Dom\Element;
20
21
/**
22
 * Class Asset
23
 *
24
 * @package O2System\HTML\DOM\Lists
25
 */
26
class Asset extends \ArrayIterator
27
{
28
    /**
29
     * Asset::$element
30
     *
31
     * @var string
32
     */
33
    public $element = 'link';
34
35
    /**
36
     * Asset::$ownerDocument
37
     *
38
     * @var \O2System\Html\Document
39
     */
40
    public $ownerDocument;
41
42
    // ------------------------------------------------------------------------
43
44
    /**
45
     * Asset::__construct
46
     *
47
     * @param \O2System\Html\Document $ownerDocument
48
     */
49
    public function __construct(Document $ownerDocument)
50
    {
51
        $this->ownerDocument =& $ownerDocument;
52
    }
53
54
    // ------------------------------------------------------------------------
55
56
    /**
57
     * Asset::import
58
     *
59
     * @param \O2System\Html\Dom\Lists\Asset $assetNodes
60
     *
61
     * @return static
62
     */
63
    public function import(Asset $assetNodes)
64
    {
65
        if (is_array($assetNodes = $assetNodes->getArrayCopy())) {
0 ignored issues
show
introduced by
The condition is_array($assetNodes = $...tNodes->getArrayCopy()) is always true.
Loading history...
66
            foreach ($assetNodes as $name => $value) {
67
                $this->offsetSet($name, $value);
68
            }
69
        }
70
71
        return $this;
72
    }
73
74
    // ------------------------------------------------------------------------
75
76
    /**
77
     * Asset::offsetSet
78
     *
79
     * @param string $name
80
     * @param string $value
81
     */
82
    public function offsetSet($name, $value)
83
    {
84
        if ($value instanceof Element) {
0 ignored issues
show
introduced by
$value is never a sub-type of O2System\Html\Dom\Element.
Loading history...
85
            parent::offsetSet($name, $value);
86
        } else {
87
            $meta = $this->ownerDocument->createElement($this->element);
88
            $meta->setAttribute($name, $value);
89
90
            parent::offsetSet($name, $meta);
0 ignored issues
show
Bug introduced by
$meta of type DOMElement is incompatible with the type string expected by parameter $newval of ArrayIterator::offsetSet(). ( Ignorable by Annotation )

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

90
            parent::offsetSet($name, /** @scrutinizer ignore-type */ $meta);
Loading history...
91
        }
92
    }
93
94
    // ------------------------------------------------------------------------
95
96
    /**
97
     * Asset::createElement
98
     *
99
     * @param array $attributes
100
     *
101
     * @return \DOMElement
102
     */
103
    public function createElement(array $attributes)
104
    {
105
        $element = $this->ownerDocument->createElement($this->element);
106
107
        $name = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $name is dead and can be removed.
Loading history...
108
        foreach ($attributes as $key => $value) {
109
            $element->setAttribute($key, $value);
110
        }
111
112
        $this[] = $element;
113
114
        return $element;
115
    }
116
}