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.
Passed
Push — master ( da157e...1438ec )
by Akpé Aurelle Emmanuel Moïse
01:18
created

BeforeStrip::setMainTags()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 16
nc 16
nop 1
dl 0
loc 21
rs 9.4222
c 0
b 0
f 0
1
<?php
2
namespace EZAMA{
3
class BeforeStrip
4
{
5
    protected $multi=false;
6
    protected $is_html=false;
7
    protected $is_php=false;
8
    protected $html=array();
9
    protected $php=array();
10
    protected $content='';
11
    protected $doctype;
12
    protected $body;
13
    protected $head;
14
    protected $html_tag;
15
    public function __construct($html)
16
    {
17
        if (!is_string($html)) {
18
            throw new \InvalidArgumentException(sprintf('Waiting string, %s given', gettype($html)));
19
        }
20
        $html=is_file($html)?file_get_contents($html):$html;
21
        $this->setMainTags($html);
22
        
23
        $html='<div>'.str_replace(
24
            array($this->doctype,$this->html_tag,'</html>',$this->head,'</head>',$this->body,'</body>'),
25
            array('<doctypetag '.substr($this->doctype, 10),'<htmltag '.substr($this->html_tag, 5),'</htmltag>','<headtag '.substr($this->head, 5),'</headtag>','<bodytag '.substr($this->body, 5),'</bodytag>'),
26
            $html
27
                              ).'</doctypetag></div>';
28
        $preprocessed=token_get_all($html);
29
        
30
        $HTML=array_filter($preprocessed, function ($v) {
31
            return is_array($v)&&$v[0]===T_INLINE_HTML;
32
        });
33
        $PHP=array_diff_key($preprocessed, $HTML);
34
        $this->init($HTML, $PHP, $html);
35
    }
36
    
37
    protected function setMainTags(&$html)
38
    {
39
        $doctypeOffset=stripos($html, '<!doctype ');
40
        $headOffset=stripos($html, '<head');
41
        $htmlTagOffset=stripos($html, '<html');
42
        $bodyOffset=stripos($html, '<body');
43
        if (false!==$doctypeOffset) {
44
            $endDoctypeOffset=strpos($html, '>', $doctypeOffset);
45
            $this->doctype=substr($html, $doctypeOffset, $endDoctypeOffset-$doctypeOffset+1);
46
        }
47
        if (false!==$headOffset) {
48
            $endHeadOffset=strpos($html, '>', $headOffset);
49
            $this->head=substr($html, $headOffset, $endHeadOffset-$headOffset+1);
50
        }
51
        if (false!==$bodyOffset) {
52
            $endBodyOffset=strpos($html, '>', $bodyOffset);
53
            $this->body=substr($html, $bodyOffset, $endBodyOffset-$bodyOffset+1);
54
        }
55
        if (false!==$htmlTagOffset) {
56
            $endHtmlTagOffset=strpos($html, '>', $htmlTagOffset);
57
            $this->html_tag=substr($html, $htmlTagOffset, $endHtmlTagOffset-$htmlTagOffset+1);
58
        }
59
    }
60
    protected function init(&$HTML, &$PHP, &$html)
61
    {
62
        list($is_h, $is_p)=array((bool)$HTML,(bool)$PHP);
63
        list($this->is_html, $this->is_php, $this->multi, $this->content, $this->html, $this->php)=array($is_h,$is_p,$is_h&&$is_p,$html,$is_p?$HTML:array(),$is_p?$PHP:array());
64
    }
65
    
66
    public function mustLoadMulti()
67
    {
68
        return $this->multi;
69
    }
70
    
71
    public function isHtml()
72
    {
73
        return $this->is_html;
74
    }
75
    public function isPHP()
76
    {
77
        return $this->is_php;
78
    }
79
    
80
    public function getPHP()
81
    {
82
        return $this->php;
83
    }
84
    
85
    public function getHTML()
86
    {
87
        return $this->html;
88
    }
89
    public function getContent()
90
    {
91
        return $this->content;
92
    }
93
    public function getDoctype()
94
    {
95
        return $this->doctype;
96
    }
97
    public function getHead()
98
    {
99
        return $this->head;
100
    }
101
    public function getBody()
102
    {
103
        return $this->body;
104
    }
105
    public function getHtmlTag()
106
    {
107
        return $this->html_tag;
108
    }
109
}
110
}
111