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.

Script::offsetSet()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
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;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * Class Script
20
 *
21
 * @package O2System\HTML\DOM
22
 */
23
class Script extends \ArrayIterator
24
{
25
    /**
26
     * Script::$hashes
27
     *
28
     * @var array
29
     */
30
    protected $hashes = [];
31
32
    // ------------------------------------------------------------------------
33
34
    /**
35
     * Script::import
36
     *
37
     * @param \O2System\Html\Dom\Script $script
38
     */
39
    public function import(Script $script)
40
    {
41
        foreach ($script->getArrayCopy() as $scriptTextContent) {
42
            $this->append($scriptTextContent);
43
        }
44
    }
45
46
    // ------------------------------------------------------------------------
47
48
    /**
49
     * Script::append
50
     *
51
     * @param string $value
52
     */
53
    public function append($value)
54
    {
55
        $value = trim($value);
56
57
        if ( ! empty($value)) {
58
59
            $hash = md5($value);
60
            if ( ! in_array($hash, $this->hashes)) {
61
                parent::append($value);
62
                $this->hashes[] = $hash;
63
            }
64
        }
65
    }
66
67
    // ------------------------------------------------------------------------
68
69
    /**
70
     * Script::offsetSet
71
     *
72
     * @param string $offset
73
     * @param string $value
74
     */
75
    public function offsetSet($offset, $value)
76
    {
77
        $value = trim($value);
78
79
        if ( ! empty($value)) {
80
            parent::offsetSet($offset, $value);
81
        }
82
    }
83
84
    // ------------------------------------------------------------------------
85
86
    /**
87
     * Script::exists
88
     *
89
     * @param string $value
90
     *
91
     * @return bool
92
     */
93
    public function exists($value)
94
    {
95
        $value = trim($value);
96
97
        if ( ! empty($value)) {
98
99
            $hash = md5($value);
100
101
            return (bool)in_array($hash, $this->hashes);
102
        }
103
104
        return false;
105
    }
106
107
    // ------------------------------------------------------------------------
108
109
    /**
110
     * Script::__toString
111
     *
112
     * @return string
113
     */
114
    public function __toString()
115
    {
116
        return PHP_EOL . implode(PHP_EOL, $this->getArrayCopy()) . PHP_EOL;
117
    }
118
}