Passed
Push — features/47-laravelmethods ( be9cc3...eb62da )
by Luke
02:31
created

Lst   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 10
cts 14
cp 0.7143
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A toArray() 0 4 1
A __invoke() 0 4 1
A count() 0 4 1
1
<?php
2
/**
3
 * Nozavroni/Collections
4
 * Just another collections library for PHP5.6+.
5
 * @version   {version}
6
 * @copyright Copyright (c) 2017 Luke Visinoni <[email protected]>
7
 * @author    Luke Visinoni <[email protected]>
8
 * @license   https://github.com/deni-zen/csvelte/blob/master/LICENSE The MIT License (MIT)
9
 */
10
namespace Noz\Collection;
11
12
use BadMethodCallException;
13
14
use Countable;
15
use Noz\Contracts\Structure\Listable;
16
use Traversable;
17
use SplDoublyLinkedList;
18
19
use Noz\Contracts\Structure\Sequenceable;
20
use Noz\Contracts\Immutable;
21
use Noz\Contracts\Arrayable;
22
use Noz\Contracts\Invokable;
23
24
use Noz\Traits\IsImmutable;
25
26
use function Noz\to_array;
27
use function Noz\is_traversable;
28
29
class Lst implements
30
    Listable,
31
    Immutable,
32
    Countable,
33
    Arrayable,
34
    Invokable
35
{
36
    use IsImmutable;
37
38
    private $data;
39
40 1
    public function __construct($data)
41
    {
42 1
        $data = array_values(to_array($data));
43 1
        $this->data = new SplDoublyLinkedList();
44 1
        $this->data->setIteratorMode(SplDoublyLinkedList::IT_MODE_KEEP);
45 1
        foreach ($data as $key => $val) {
46 1
            $this->data->add($key, $val);
47 1
        }
48 1
    }
49
50
    /**
51
     * To array.
52
     *
53
     * @return array
54
     */
55 1
    public function toArray()
56
    {
57 1
        return to_array($this->data);
58
    }
59
60
    /**
61
     * Invoke set.
62
     *
63
     * @return mixed
64
     */
65
    public function __invoke()
66
    {
67
        // TODO: Implement __invoke() method.
68
    }
69
70
    /**
71
     * Count elements of an object
72
     * @link  http://php.net/manual/en/countable.count.php
73
     * @return int The custom count as an integer.
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
74
     * </p>
75
     * <p>
76
     * The return value is cast to an integer.
77
     * @since 5.1.0
78
     */
79
    public function count()
80
    {
81
        // TODO: Implement count() method.
82
    }
83
84
}