Collection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 2
c 5
b 0
f 1
lcom 0
cbo 3
dl 0
loc 28
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromHtml() 0 4 1
A fromArray() 0 4 1
1
<?php
2
3
namespace Jne\Collections;
4
5
use Jne\Contracts\MapperInterface;
6
use Jne\Contracts\HtmlMapperInterface;
7
use Symfony\Component\DomCrawler\Crawler;
8
use Illuminate\Support\Collection as BaseCollection;
9
use Jne\Contracts\Collections\CollectionInterface;
10
11
class Collection extends BaseCollection implements CollectionInterface
12
{
13
    /**
14
     * Create collection instance from raw array.
15
     *
16
     * @param array                          $data
17
     * @param \Jne\Contracts\MapperInterface $mapper
18
     *
19
     * @return \Jne\Contracts\CollectionsInterface
20
     */
21 4
    public static function fromArray(array $data, MapperInterface $mapper)
22
    {
23 4
        return new static($mapper->map($data));
24
    }
25
26
    /**
27
     * Create collection instance from HTML node.
28
     *
29
     * @param \Symfony\Component\DomCrawler\Crawler $node
30
     * @param \Jne\Contracts\HtmlMapperInterface    $htmlMapper
31
     *
32
     * @return \Jne\Contracts\CollectionsInterface
33
     */
34 2
    public static function fromHtml(Crawler $node, HtmlMapperInterface $htmlMapper)
35
    {
36 2
        return new static($htmlMapper->map($node));
37
    }
38
}
39