Completed
Push — master ( beccd2...66b328 )
by Vitaly
02:25
created

Tree::analyzeSourceNode()   D

Complexity

Conditions 9
Paths 18

Size

Total Lines 41
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 41
rs 4.909
cc 9
eloc 19
nc 18
nop 2
1
<?php
2
namespace samsonframework\html2less;
3
4
/**
5
 * Created by Vitaly Iegorov <[email protected]>.
6
 * on 15.04.16 at 12:43
7
 */
8
class Tree
9
{
10
    /** @var array Collection of ignored DOM nodes */
11
    public static $ignoredNodes = array(
12
        'head',
13
        'meta',
14
        'script',
15
        'noscript',
16
        'link',
17
        'title',
18
        'br',
19
    );
20
21
    public function __construct()
22
    {
23
        $example = <<<'HTML'
24
        <html lang="en"><head>
25
<base href="/">
26
<script type="text/javascript" id="www-widgetapi-script" src="https://s.ytimg.com/yts/jsbin/www-widgetapi-vfl0mFVOk/www-widgetapi.js" async=""></script><script type="text/javascript" async="" src="http://www.google-analytics.com/analytics.js"></script><script src="https://www.youtube.com/iframe_api"></script><script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-WWZ2DS"></script><script type="text/javascript">var __SAMSONPHP_STARTED = new Date().getTime();</script>
27
<!--[if lt IE 9]>
28
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
29
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
30
<![endif]-->
31
        <title>Pray for Ukraine</title>
32
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
33
        <meta name="google-site-verification" content="P7vIywlGAp7AXpXBP8mk3Q9s4QG0MSph3IoRzR9Yx4U">
34
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
35
        <!-- Latest 3.2.x goodshare.js minify version from jsDelivr CDN -->
36
        <script src="https://cdn.jsdelivr.net/jquery.goodshare.js/3.2.5/goodshare.min.js"></script>
37
        <link property="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,700italic,300italic,300,400italic&amp;subset=latin,cyrillic" rel="stylesheet" type="text/css">
38
    <link rel="alternate" lang="uk" href="http://prayforukraine.dev/ua/"><link rel="alternate" lang="ru" href="http://prayforukraine.dev/ru/http://prayforukraine.dev/ua/">
39
<link type="text/css" rel="stylesheet" href="/cache/resourcer/default/bb5d08be43e350c3df6dbd4cd7f81e97.css">
40
</head>
41
42
    <body id="main">
43
        <section class="header">
44
            <h6 hidden="">Header</h6>
45
            <div class="inner-section">
46
                <a class="logo-img" href="http://prayforukraine.dev"></a>
47
                <a class="logo-word" href="http://prayforukraine.dev"></a>
48
49
                <div class="close menu-open"></div>
50
                <nav class="menu">
51
                    <div class="locale">
52
                        <!-- i18n Locale selection block Created by Vitaly Iegorov <[email protected]> on 07.03.14 at 12:03 start -->
53
<div class="i18n-current" style="display: none;">
54
    en</div>
55
<ul class="i18n-list">
56
    <li class="i18n-locale-en i18n-active">
57
    <a href="http://prayforukraine.dev/"></a>
58
</li><li class="i18n-locale-ua ">
59
    <a href="http://prayforukraine.dev/ua/"></a>
60
</li><li class="i18n-locale-ru ">
61
    <a href="http://prayforukraine.dev/ru/"></a>
62
</li></ul>
63
<!-- i18n Locale selection block Created by Vitaly Iegorov <[email protected]> on 07.03.14 at 12:03 end -->                    </div>
64
                    <a class="menu-text" id="projects-link" href="http://prayforukraine.dev/projects/">projects</a>
65
                    <a class="menu-text" id="news-link" href="http://prayforukraine.dev/news/">news</a>
66
                    <a class="menu-text" id="team-link" href="http://prayforukraine.dev/team/">our team</a>
67
                    <div class="button orange open-popup">Donate</div>
68
                </nav>
69
            </div>
70
        </section>
71
72
        <!-- PAGE BLOCK -->
73
<section class="page main-page" style="background-image: url(/view/?p=/src/main/www/img/page.png)">
74
    <h6 class="big-text">
75
        DONATE<br>SAVE LIVES TOGETHER    </h6>
76
    <div class="center">
77
        <div class="button orange scroll-button">
78
            Donate now        </div>
79
    </div>
80
</section>
81
82
<div class="video-color">
83
    <section class="video">
84
        <h6 hidden="">Video</h6>
85
        <div class="image"></div>
86
                    <div class="center">
87
                <div class="center-video-button"></div>
88
                <iframe class="video-youtube" id="YVjPznbAtmA" frameborder="0" allowfullscreen="1" title="YouTube video player" width="638" height="355" src="https://www.youtube.com/embed/YVjPznbAtmA?rel=0&amp;autohide=1&amp;controls=0&amp;showinfo=0&amp;enablejsapi=1&amp;origin=http%3A%2F%2Fprayforukraine.dev"></iframe>
89
            </div>
90
            </section>
91
</div>
92
93
<!-- PROJECTS BLOCK -->
94
у
95
<section class="projects">
96
    <div class="inner-section">
97
        <div class="list-projects">
98
    <div class="swiper-button-prev swiper-button-prev-projects swiper-button-disabled"></div>
99
    <div class="swiper-container swiper-container-horizontal swiper-projects">
100
        <div class="swiper-wrapper">
101
            <div onclick="location.href='http://prayforukraine.dev/projects/projects-29/'" class="one-project swiper-slide swiper-slide-active">
102
    <div class="photo" style="background-image: url('')"></div>
103
    <div class="description">
104
        <div class="title">
105
            Test        </div>
106
        <div class="text">
107
            Test info        </div>
108
    </div>
109
            <div class="center">
110
            <a onclick="location.href='http://prayforukraine.dev/projects/projects-29/'" class="button white">learn more</a>
111
        </div>
112
    </div><div onclick="location.href='http://prayforukraine.dev/projects/portable-medical-equipment/'" class="one-project swiper-slide swiper-slide-next">
113
    <div class="photo" style="background-image: url('/upload/2cc3b934e2015910bc152b10341af8f7.jpg')"></div>
114
    <div class="description">
115
        <div class="title">
116
            PORTABLE MEDICAL EQUIPMENT        </div>
117
        <div class="text">
118
            Pray for Ukraine collects donations to provide necessary items such as military equipment and medicines. Military special forces in the Eastern region of Ukraine continue to carry out its primary duty - to protect especially important sites covering the state border and protect the civilian population.         </div>
119
    </div>
120
            <div class="center">
121
            <a onclick="location.href='http://prayforukraine.dev/projects/portable-medical-equipment/'" class="button white">learn more</a>
122
        </div>
123
    </div><div onclick="location.href='http://prayforukraine.dev/projects/firstaidkit/'" class="one-project swiper-slide">
124
    <div class="photo" style="background-image: url('/upload/5472d2827386fb3a3d834708209390a6.jpeg')"></div>
125
    <div class="description">
126
        <div class="title">
127
            Individual First Aid Kit        </div>
128
        <div class="text">
129
            The Individual First Aid Kit, or IFAK, gives a soldier the ability to administer Self-Aid/Buddy-Aid and provides a path for intervention of two leading causes of death on the battlefield, severe hemorrhaging and blocked airways        </div>
130
    </div>
131
            <div class="center">
132
            <a onclick="location.href='http://prayforukraine.dev/projects/firstaidkit/'" class="button white">learn more</a>
133
        </div>
134
    </div><div onclick="location.href='http://prayforukraine.dev/projects/shelter-chervonoarmiysk/'" class="one-project swiper-slide">
135
    <div class="photo" style="background-image: url('/upload/5c5ebda197c9c53ab9272d33ab5eeb6c.jpg')"></div>
136
    <div class="description">
137
        <div class="title">
138
            Help shelter for child victims of war        </div>
139
        <div class="text">
140
            Shelter Chervonoarmiysk is for 30 children who lost their parents because of the war. A few miles from their destroyed homes        </div>
141
    </div>
142
            <div class="center">
143
            <a onclick="location.href='http://prayforukraine.dev/projects/shelter-chervonoarmiysk/'" class="button white">learn more</a>
144
        </div>
145
    </div><div onclick="location.href='http://prayforukraine.dev/projects/help-disabled-children-veronika/'" class="one-project swiper-slide">
146
    <div class="photo" style="background-image: url('/upload/337a7990213c708c97216461ecfa443a.png')"></div>
147
    <div class="description">
148
        <div class="title">
149
            Help Veronika to live, 3 years, bone marrow cancer        </div>
150
        <div class="text">
151
            Help Veronika to live, 3 years, bone marrow cancer        </div>
152
    </div>
153
            <div class="center">
154
            <a onclick="location.href='http://prayforukraine.dev/projects/help-disabled-children-veronika/'" class="button white">learn more</a>
155
        </div>
156
    </div>        </div>
157
    </div>
158
    <div class="swiper-button-next swiper-button-next-projects"></div>
159
</div>    </div>
160
</section>
161
<!-- TEAM BLOCK -->
162
<section class="team">
163
    <div class="inner-section">
164
        <div class="header-text">Our team</div>
165
        <div class="all-people">
166
    <div class="one">
167
    <a class="photo" href="http://prayforukraine.dev/team/yaroslav-kandyba/" style="background-image: url('/upload/bb3a1d725df000114e85470a2253cddb.png')">
168
    <span>sdfds</span>
169
</a>
170
    <a class="social" href="https://www.facebook.com/profile.php?id=100011337422732&amp;fref=ts"></a>
171
    <div class="description">
172
        <div class="name">
173
            Yaroslav Kandyba        </div>
174
        <div class="text">
175
            <p>Yaroslav is founder of Pray for Ukraine foundation. He helps children who became victims of war, who lost their parents. From age of 4 to 18 they got serious problems with health, they don't have place where to live, nothing to eat and to wear. Also Yaroslav collects aid for people who needs immediately medical help. Also soldier collects aid for army needs such as warm clothing, uniforms, first aid kits.</p><p></p>        </div>
176
                    <a href="http://prayforukraine.dev/team/yaroslav-kandyba/ " class="more-info">More</a>
177
            </div>
178
</div><div class="one">
179
    <a class="photo" href="http://prayforukraine.dev/team/yurii-bodnar/" style="background-image: url('/upload/99ee88634efc76d33d9e2a1d6c7b802a.jpg')"></a>
180
    <a class="social" href="https://www.facebook.com/profile.php?id=100007071728288&amp;sk=photos"></a>
181
    <div class="description">
182
        <div class="name">
183
            Yurii Bodnar        </div>
184
        <div class="text">
185
186
187
188
189
190
191
192
<p class="p1"><span class="s1" style="font-size: 14px; font-family: Arial;">Yurii has been being volunteer and soldier in Ukraine army for the 2nd year. His dangerous profession became his way of life. Every day Yurii helps to survive his colleagues. He collects aid for the most necessary things military - equipment for the conduct of defense and medical suppliements. </span></p>        </div>
193
                    <a href="http://prayforukraine.dev/team/yurii-bodnar/ " class="more-info">More</a>
194
            </div>
195
</div><div class="one">
196
    <a class="photo" href="http://prayforukraine.dev/team/taras-chmut/" style="background-image: url('/upload/7fdff13b16a629da550c0abd009b0db4.jpg')"></a>
197
    <a class="social" href="https://www.facebook.com/profile.php?id=100003822077764&amp;fref=ts"></a>
198
    <div class="description">
199
        <div class="name">
200
            Taras Chmut        </div>
201
        <div class="text">
202
            Taras is only 24, but he can already proud about himself. He works volunteer and soldier in <span style="font-family: Arial; font-size: 14px;">the Naval Forces of Ukraine. He decided that he could not stay apart when his country is in danger. Taras decided to work in ukrainian navy because there are soldiers who are worth to be like them. Taras knew from childhood that only strong men work in naval forces. besides, there are many problem in ukrainian navy. First of all the lack of equipment for protection against attacks of the occupier. </span>        </div>
203
                    <a href="http://prayforukraine.dev/team/taras-chmut/ " class="more-info">More</a>
204
            </div>
205
</div><div class="one">
206
    <a class="photo" href="http://prayforukraine.dev/team/ihor-fedirko/" style="background-image: url('/upload/4d6604dc9ccf08773582c03df09dc811.jpg')"></a>
207
    <a class="social" href="https://www.facebook.com/igor.fedirko?fref=ts"></a>
208
    <div class="description">
209
        <div class="name">
210
            Ihor Fedirko        </div>
211
        <div class="text">
212
213
214
215
216
217
218
219
<p class="p1"><span style="font-family: Arial;"><span class="s1" style="font-size: 14px;">Ihor works as a volunteer in </span><span class="s2"><span style="font-size: 14px;">3-rd and 8-th individual regiments of the Main Intelligence Directorate of the Ministry of Defence of Ukraine and 73-th and 140-th Centers for Special Purposes. The situation in battalions is extremely dangerous - warm clothes and medicines are running out. Soldiers of groups can not organize a high-quality surveillance of enemy equipment because of lack of modern equipment. Ihor helps his colleagues to collect money to buy all the necessary equipment.</span><span style="font-size: 14px;"> </span></span></span></p>        </div>
220
                    <a href="http://prayforukraine.dev/team/ihor-fedirko/ " class="more-info">More</a>
221
            </div>
222
</div></div>        <div class="header-text last">
223
            OUR CURRENT FUNDRAISING PROJECTS AND APPEALS        </div>
224
    </div>
225
</section>
226
<!-- PROJECTS BLOCK -->
227
<section class="projects all-more">
228
    <div class="inner-section">
229
        <div class="list-projects">
230
    <div class="swiper-button-prev swiper-button-prev-specific swiper-button-disabled"></div>
231
    <div class="swiper-container swiper-container-horizontal swiper-specific">
232
        <div class="swiper-wrapper">
233
            <div onclick="location.href='http://prayforukraine.dev/projects/projects-29/'" class="one-project swiper-slide swiper-slide-active" style="width: 235px;">
234
    <div class="photo" style="background-image: url('')"></div>
235
    <div class="description">
236
        <div class="title">
237
            Test        </div>
238
        <div class="text">
239
            Test info        </div>
240
    </div>
241
    </div><div onclick="location.href='http://prayforukraine.dev/projects/portable-medical-equipment/'" class="one-project swiper-slide swiper-slide-next" style="width: 235px;">
242
    <div class="photo" style="background-image: url('/upload/2cc3b934e2015910bc152b10341af8f7.jpg')"></div>
243
    <div class="description">
244
        <div class="title">
245
            PORTABLE MEDICAL EQUIPMENT        </div>
246
        <div class="text">
247
            Pray for Ukraine collects donations to provide necessary items such as military equipment and medicines. Military special forces in the Eastern region of Ukraine continue to carry out its primary duty - to protect especially important sites covering the state border and protect the civilian population.         </div>
248
    </div>
249
    </div><div onclick="location.href='http://prayforukraine.dev/projects/firstaidkit/'" class="one-project swiper-slide" style="width: 235px;">
250
    <div class="photo" style="background-image: url('/upload/5472d2827386fb3a3d834708209390a6.jpeg')">
251
    <i class="cur"></i>
252
</div>
253
    <div class="description">
254
        <div class="title">
255
            Individual First Aid Kit        </div>
256
        <div class="text">
257
            The Individual First Aid Kit, or IFAK, gives a soldier the ability to administer Self-Aid/Buddy-Aid and provides a path for intervention of two leading causes of death on the battlefield, severe hemorrhaging and blocked airways        </div>
258
    </div>
259
    </div><div onclick="location.href='http://prayforukraine.dev/projects/shelter-chervonoarmiysk/'" class="one-project swiper-slide" style="width: 235px;">
260
    <div class="photo" style="background-image: url('/upload/5c5ebda197c9c53ab9272d33ab5eeb6c.jpg')"></div>
261
    <div class="description">
262
        <div class="title">
263
            Help shelter for child victims of war        </div>
264
        <div class="text">
265
            Shelter Chervonoarmiysk is for 30 children who lost their parents because of the war. A few miles from their destroyed homes        </div>
266
    </div>
267
    </div><div onclick="location.href='http://prayforukraine.dev/projects/help-disabled-children-veronika/'" class="one-project swiper-slide" style="width: 235px;">
268
    <div class="photo" style="background-image: url('/upload/337a7990213c708c97216461ecfa443a.png')">
269
    <span>dsdfsd</span>
270
</div>
271
    <div class="description">
272
        <div class="title">
273
            Help Veronika to live, 3 years, bone marrow cancer        </div>
274
        <div class="text">
275
            Help Veronika to live, 3 years, bone marrow cancer        </div>
276
    </div>
277
    </div>        </div>
278
    </div>
279
    <div class="swiper-button-next swiper-button-next-specific"></div>
280
</div>        <div class="center">
281
            <a class="button white" href="http://prayforukraine.dev/projects/">learn more</a>
282
        </div>
283
    </div>
284
</section>        <!-- FOOTER SECTION -->
285
        <div id="popup-message">
286
    <div class="popup-close"></div>
287
    <div class="text"></div>
288
</div>
289
290
<div id="footer-message">
291
    <div class="popup-close"></div>
292
    <div class="text"></div>
293
</div>
294
295
<section class="footer">
296
    <div class="email-block">
297
        <h6>
298
            TOGETHER WE CAN MAKE A DIFFERENCE        </h6>
299
        <div class="select-phone">
300
    <select class="select">
301
        <option value="1">$1</option>
302
        <option value="5">$5</option>
303
        <!--        <option value="10">$10</option>-->
304
        <option value="20">$20</option>
305
        <option value="50">$50</option>
306
        <option value="100">$100</option>
307
        <option value="500">$500</option>
308
    </select>
309
</div>
310
<div class="select-money">
311
    <div class="one active" data-value="1">$1</div>
312
    <div class="one" data-value="5">$5</div>
313
    <!--    <div class="one" data-value="10">$10</div>-->
314
    <div class="one" data-value="20">$20</div>
315
    <div class="one" data-value="50">$50</div>
316
    <div class="one" data-value="100">$100</div>
317
    <div class="one" data-value="500">$500</div>
318
</div>        <input type="text" id="footer-input" placeholder="Or enter donation value">
319
        <div class="over-payment">
320
            <div class="info-payment">
321
322
                <div class="info-donator">
323
                    <input type="email" class="gray donator-input" id="footer-donator-email-input" name="email-donator" placeholder="Input your e-mail"><br>
324
                    <input type="text" class="gray donator-input" id="footer-donator-input" name="name-donator" placeholder="Input your name">
325
                </div>
326
327
                <!--                <div class="payment-header">-->
328
                <!--</div>-->
329
                <div class="lists-bank">
330
                    <div class="phone swiper-button-prev swiper-button-prev-footer"></div>
331
                    <div class="swiper-container swiper-footer">
332
                        <div class="swiper-wrapper">
333
    <div class="one">
334
    <!--    <div class="up-bank hidden"></div>-->
335
    <div class="lightpay"></div>
336
</div></div>                    </div>
337
                    <div class="phone swiper-button-next swiper-button-next-footer"></div>
338
                </div>
339
            </div>
340
        </div>
341
342
        <div class="buttons">
343
            <div class="button blue">single donation</div>
344
            <div class="button">give monthly</div>
345
        </div>
346
347
        <div class="share-hidden">
348
            <div class="share">
349
                <div class="share-header">
350
                    Share with your friends                </div>
351
352
                <div class="all-share">
353
                    <a class="goodshare one-share fb" data-type="fb" href="#"></a>
354
                    <a class="goodshare one-share tw" data-type="tw" href="#"></a>
355
                    <a class="goodshare one-share gp" data-type="gp" href="#"></a>
356
                </div>
357
            </div>
358
        </div>
359
    </div>
360
361
    <div class="info-block">
362
        <h5 class="info-header">
363
            HELP US TO SAVE UKRAINIAN LIVES        </h5>
364
        <div class="under-header">
365
            why Ukraine?        </div>
366
367
        <div class="inner-section">
368
    <div class="informations">
369
        <div class="one-info">
370
    <div class="numbers">
371
        18 000    </div>
372
    <div class="description">
373
        <p>people have died</p><p> in undeclared war</p>    </div>
374
</div>
375
&nbsp;<div class="one-info">
376
    <div class="numbers">
377
        1 200    </div>
378
    <div class="description">
379
        <p>among them</p><p>children</p>    </div>
380
</div>
381
&nbsp;<div class="one-info">
382
    <div class="numbers">
383
        30 290    </div>
384
    <div class="description">
385
        <div>injured and</div><div>hospitalized</div>    </div>
386
</div>
387
&nbsp;<div class="one-info">
388
    <div class="numbers">
389
        118 000    </div>
390
    <div class="description">
391
        <div>Children left</div><div>orphans and</div><div>disabled</div>    </div>
392
</div>
393
&nbsp;<div class="one-info">
394
    <div class="numbers">
395
        2 638 000    </div>
396
    <div class="description">
397
        <p>people were forced</p><p> to leave </p><p>their homes<br></p>    </div>
398
</div>
399
&nbsp;    </div>
400
</div>
401
        <div class="big-text">
402
            TOGETHER WE CAN MAKE A DIFFERENCE        </div>
403
404
        <div class="button orange scroll-button">
405
            Donate now        </div>
406
407
        <div class="share">
408
            <div class="share-header">
409
                Share with your friends            </div>
410
            <div class="all-share">
411
                <a class="one-share fb" href="https://www.facebook.com/prayforukraine.org.ua"></a>
412
                <a class="one-share tw" href="https://twitter.com/"></a>
413
                <a class="one-share gp" href="https://plus.google.com/"></a>
414
            </div>
415
        </div>
416
    </div>
417
</section>
418
        <!-- POPUP SECTION -->
419
        <div class="all-page"></div>
420
421
<section class="popup" id="popup">
422
    <h6 hidden="">Popup</h6>
423
    <div class="email-block">
424
425
        <div class="popup-header">
426
            DONATE            <div class="close-popup"></div>
427
        </div>
428
429
        <div class="select-phone">
430
    <select class="select">
431
        <option value="1">$1</option>
432
        <option value="5">$5</option>
433
        <!--        <option value="10">$10</option>-->
434
        <option value="20">$20</option>
435
        <option value="50">$50</option>
436
        <option value="100">$100</option>
437
        <option value="500">$500</option>
438
    </select>
439
</div>
440
<div class="select-money">
441
    <div class="one active" data-value="1">$1</div>
442
    <div class="one" data-value="5">$5</div>
443
    <!--    <div class="one" data-value="10">$10</div>-->
444
    <div class="one" data-value="20">$20</div>
445
    <div class="one" data-value="50">$50</div>
446
    <div class="one" data-value="100">$100</div>
447
    <div class="one" data-value="500">$500</div>
448
</div>
449
        <input type="text" id="popup-input" placeholder="Or enter donation value">
450
451
        <div class="over-payment">
452
            <div class="info-payment">
453
454
                <div class="info-donator">
455
                    <input type="email" class="gray donator-input" id="popup-donator-email-input" name="email-donator" placeholder="Input your e-mail"><br>
456
                    <input type="text" class="gray donator-input" id="popup-donator-input" placeholder="Input your name" name="name-donator">
457
                </div>
458
459
                <!--                <div class="payment-header">-->
460
                <!--</div>-->
461
                <div class="lists-bank">
462
                    <div class="phone swiper-button-prev swiper-button-prev-popup"></div>
463
                    <div class="swiper-container swiper-popup">
464
                        <div class="swiper-wrapper">
465
    <div class="one">
466
    <!--    <div class="up-bank hidden"></div>-->
467
    <div class="lightpay"></div>
468
</div></div>                    </div>
469
                    <div class="phone swiper-button-next swiper-button-next-popup"></div>
470
                </div>
471
            </div>
472
        </div>
473
474
        <div class="buttons">
475
            <div class="button blue">single donation</div>
476
            <div class="button">give monthly</div>
477
        </div>
478
479
        <div class="share-hidden">
480
            <div class="popup-thanks"></div>
481
            <div class="share">
482
                <div class="share-header">
483
                    Share with your friends                </div>
484
485
                <div class="all-share">
486
                    <a class="goodshare one-share fb" data-type="fb" href="#"></a>
487
                    <a class="goodshare one-share tw" data-type="tw" href="#"></a>
488
                    <a class="goodshare one-share gp" data-type="gp" href="#"></a>
489
                </div>
490
            </div>
491
        </div>
492
    </div>
493
</section>
494
        <section class="popup" id="popup-thanks-payment">
495
            <div class="email-block">
496
                <div class="popup-header">
497
                    Thank you for your donation!
498
                    <div class="close-popup"></div>
499
                </div>
500
501
                <div class="share-hidden" style="display: block;">
502
                    <div class="share">
503
                        <div class="share-header">
504
                            Share with your friends
505
                        </div>
506
                        <div class="all-share">
507
                            <a class="goodshare one-share fb" data-type="fb" href="#"></a>
508
                            <a class="goodshare one-share tw" data-type="tw" href="#"></a>
509
                            <a class="goodshare one-share gp" data-type="gp" href="#"></a>
510
                        </div>
511
                    </div>
512
                </div>
513
            </div>
514
        </section>
515
516
        <!-- Google Tag Manager -->
517
        <noscript>&lt;iframe src="//www.googletagmanager.com/ns.html?id=GTM-WWZ2DS"
518
                          height="0" width="0" style="display:none;visibility:hidden"&gt;&lt;/iframe&gt;</noscript>
519
        <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
520
                new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
521
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
522
                '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
523
            })(window,document,'script','dataLayer','GTM-WWZ2DS');</script>
524
        <!-- End Google Tag Manager -->
525
526
<script type="text/javascript" src="/cache/resourcer/default/52f7a218fc1ffe5f12080fd5a664c7f5.js"></script><div class="__loader_bg" style="display: none;"><div class="__loader_middle"><div id="canvas-loader_2170" class="__loader_canvas"><div id="canvasLoader" style="display: block;"><canvas width="72" height="72"></canvas><canvas width="72" height="72" style="display: none;"></canvas></div></div><div class="text"></div></div></div>
527
528
</body></html>
529
HTML;
530
        trace($this->build($example), 1);
531
    }
532
533
    /**
534
     * Build destination code tree from source code.
535
     *
536
     * @param string $source Source code
537
     */
538
    public function build($source)
539
    {
540
        // Prepare source code
541
        $source = $this->prepare($source);
542
543
        // Build destination node tree
544
        $tree = $this->analyze($source);
545
546
        return $this->output($tree, $output);
547
    }
548
549
    /**
550
     * Source code cleaner.
551
     *
552
     * @param string $source
553
     *
554
     * @return string Cleared source code
555
     */
556
    protected function prepare($source)
557
    {
558
        // Remove all PHP code from view
559
        return trim(preg_replace('/<\?(php|=).*?\?>/', '', $source));
560
    }
561
562
    /**
563
     * Analyze source code and create destination code tree.
564
     *
565
     * @param string $source Source code
566
     *
567
     * @return LessNode Internal code tree
568
     */
569
    protected function &analyze($source)
570
    {
571
        libxml_use_internal_errors(true);
572
573
        /** @var \DOMNode Pointer to current dom element */
574
        $dom = new \DOMDocument();
575
        $dom->loadHTML($source);
576
577
        // Perform recursive node analysis
578
        return $this->analyzeSourceNode($dom, new LessNode(''));
579
    }
580
581
    /**
582
     * Perform source node analysis.
583
     *
584
     * @param \DOMNode $domNode
585
     * @param LessNode $parent
586
     *
587
     * @return LessNode
588
     */
589
    protected function &analyzeSourceNode(\DOMNode $domNode, LessNode $parent)
590
    {
591
        foreach ($domNode->childNodes as $child) {
592
            $tag = $child->nodeName;
593
594
            // Work only with allowed DOMElements
595
            if ($child->nodeType === 1 && !in_array($tag, static::$ignoredNodes)) {
596
                // Get node classes
597
                $classes = array_filter(explode(' ', $this->getDOMAttributeValue($child, 'class')));
598
599
                // Define less node selector
600
                $selector = $tag;
601
                if (($identifier = $this->getDOMAttributeValue($child, 'id')) !== null) {
602
                    $selector = '#' . $identifier;
603
                } elseif (count($classes)) {
604
                    $selector = '.' . array_shift($classes);
605
                } elseif (($name = $this->getDOMAttributeValue($child, 'name')) !== null) {
606
                    $selector = $tag . '[name=' . $name . ']';
607
                }
608
609
                // Find child node by selector
610
                $node = $parent->getChild($selector);
611
612
                // Check if we have created this selector LessNode for this branch
613
                if (null === $node) {
614
                    // Create internal node instance
615
                    $node = new LessNode($selector, $parent);
0 ignored issues
show
Documentation introduced by
$parent is of type object<samsonframework\html2less\LessNode>, but the function expects a null|object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
616
                }
617
618
                // Create inner class modifiers for parent node
619
                foreach ($classes as $class) {
620
                    new LessNode('&.' . $class, $node);
0 ignored issues
show
Documentation introduced by
$node is of type object<samsonframework\html2less\LessNode>, but the function expects a null|object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
621
                }
622
623
                // Go deeper in recursion
624
                $this->analyzeSourceNode($child, $node);
625
            }
626
        }
627
628
        return $parent;
629
    }
630
631
    /**
632
     * Get DOM node attribute value.
633
     *
634
     * @param \DOMNode $domNode
635
     * @param string   $attributeName
636
     *
637
     * @return null|string DOM node attribute value
638
     */
639
    protected function getDOMAttributeValue(\DOMNode $domNode, $attributeName)
640
    {
641
        if (null !== $domNode->attributes) {
642
            /**@var \DOMNode $attribute */
643
            foreach ($domNode->attributes as $attribute) {
644
                $value = trim($attribute->nodeValue);
645
                // If DOM attribute matches needed
646
                if ($attributeName === $attribute->name && $value !== '') {
647
                    // Remove white spaces
648
                    return $value;
649
                }
650
            }
651
        }
652
653
        return null;
654
    }
655
656
    /**
657
     * @param LessNode $node
658
     * @param string   $output
659
     * @param int      $level
660
     *
661
     * @return string
662
     */
663
    public function output(LessNode $node, &$output = '', $level = 0)
664
    {
665
        // Generate tabs array
666
        $output .= implode('', array_fill(0, $level, '  ')) . $node . "\n";
667
668
        foreach ($node->children as $child) {
0 ignored issues
show
Bug introduced by
The expression $node->children of type object<samsonframework\html2less\LessNode> is not traversable.
Loading history...
669
            $this->output($child, $output, $level + 1);
670
        }
671
672
        return $output;
673
    }
674
}
675