Passed
Pull Request — master (#149)
by Pierre
03:06
created

CollectionSpec   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 56
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_countable() 0 3 1
A it_should_entry_if_it_exists() 0 4 1
A its_offsetUnset_method_cannot_be_called() 0 3 1
A it_is_initializable() 0 3 1
A it_counts_entries() 0 3 1
A its_offsetSet_method_cannot_be_called() 0 3 1
A it_is_iterable() 0 3 1
A let() 0 5 1
A it_is_an_array_access() 0 3 1
A it_is_a_list_ob_dictionaries() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Knp\DictionaryBundle\Dictionary;
6
7
use ArrayAccess;
8
use Countable;
9
use IteratorAggregate;
10
use Knp\DictionaryBundle\Dictionary;
11
use Knp\DictionaryBundle\Dictionary\Collection;
12
use PhpSpec\ObjectBehavior;
13
use RuntimeException;
14
15
final class CollectionSpec extends ObjectBehavior
16
{
17
    function let(Dictionary $dictionary, Dictionary $dictionary2)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19
        $this->beConstructedWith($dictionary, $dictionary2);
20
        $dictionary->getName()->willReturn('foo');
21
        $dictionary2->getName()->willReturn('dictionary');
22
    }
23
24
    function it_is_initializable()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
    {
26
        $this->shouldHaveType(Collection::class);
27
    }
28
29
    function it_is_an_array_access()
30
    {
31
        $this->shouldHaveType(ArrayAccess::class);
32
    }
33
34
    function it_is_iterable()
35
    {
36
        $this->shouldHaveType(IteratorAggregate::class);
37
    }
38
39
    function it_is_countable()
40
    {
41
        $this->shouldHaveType(Countable::class);
42
    }
43
44
    function it_should_entry_if_it_exists($dictionary)
0 ignored issues
show
Unused Code introduced by
The parameter $dictionary is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

44
    function it_should_entry_if_it_exists(/** @scrutinizer ignore-unused */ $dictionary)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
45
    {
46
        $this->offsetExists('foo')->shouldBe(true);
47
        $this->offsetExists('baz')->shouldBe(false);
48
    }
49
50
    function it_counts_entries()
51
    {
52
        $this->count()->shouldReturn(2);
0 ignored issues
show
Bug introduced by
The method count() does not exist on spec\Knp\DictionaryBundl...ctionary\CollectionSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
        $this->/** @scrutinizer ignore-call */ 
53
               count()->shouldReturn(2);
Loading history...
53
    }
54
55
    function it_is_a_list_ob_dictionaries($dictionary, $dictionary2)
56
    {
57
        $this->getIterator()->getArrayCopy()->shouldReturn([
0 ignored issues
show
Bug introduced by
The method getIterator() does not exist on spec\Knp\DictionaryBundl...ctionary\CollectionSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        $this->/** @scrutinizer ignore-call */ 
58
               getIterator()->getArrayCopy()->shouldReturn([
Loading history...
58
            'foo'        => $dictionary,
59
            'dictionary' => $dictionary2,
60
        ]);
61
    }
62
63
    function its_offsetSet_method_cannot_be_called()
64
    {
65
        $this->shouldThrow(RuntimeException::class)->duringOffsetSet('foo', 'bar');
66
    }
67
68
    function its_offsetUnset_method_cannot_be_called()
69
    {
70
        $this->shouldThrow(RuntimeException::class)->duringOffsetUnset('foo');
71
    }
72
}
73