HtmlElements   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A newData() 0 3 1
A toArray() 0 7 1
1
<?php
2
3
namespace Ghc\Rosetta\Messages;
4
5
use Symfony\Component\DomCrawler\Crawler;
6
7
class HtmlElements extends Xml
8
{
9
    /**
10
     * Boot Transformer.
11
     */
12
    protected function boot()
13
    {
14
        $this->addDefaultConfig([
15
            'selector' => 'html',
16
        ]);
17
    }
18
19
    /**
20
     * @return string
21
     */
22
    public function newData()
23
    {
24
        return '<html></html>';
25
    }
26
27
    /**
28
     * Get the instance as an array.
29
     *
30
     * @return array
31
     */
32
    public function toArray()
33
    {
34
        $crawler = new Crawler((string) $this->getData());
35
36
        return $crawler->filter($this->getConfig()['selector'])->each(function ($element) {
37
            /* @var Crawler $element */
38
            return $this->domNodeToArray($element->getNode(0));
39
        });
40
    }
41
}
42