DataSourceCollectionTestCase   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 100
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A randomValue() 0 4 1
A uniqueValue() 0 4 1
A testCreate() 0 9 1
A testCount() 0 12 1
A testGetIterator() 0 12 1
A testSlice() 0 13 1
A testSorted() 0 16 1
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Cubiche\Core\Collections\Tests\Units;
11
12
use Cubiche\Core\Collections\LazyCollection\LazyCollection;
13
use Cubiche\Core\Comparable\Comparator;
14
15
/**
16
 * DataSourceCollectionTestCase trait.
17
 *
18
 * @author Ivannis Suárez Jerez <[email protected]>
19
 * @author Karel Osorio Ramírez <[email protected]>
20
 */
21
trait DataSourceCollectionTestCase
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function randomValue()
27
    {
28
        return \rand(0, 100);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function uniqueValue()
35
    {
36
        return 1000;
37
    }
38
39
    /*
40
     * Test create.
41
     */
42
    public function testCreate()
43
    {
44
        $this
0 ignored issues
show
Bug introduced by
It seems like given() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
45
            ->given($collection = $this->randomCollection())
0 ignored issues
show
Bug introduced by
It seems like randomCollection() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
46
            ->then()
47
                ->collection($collection)
48
                    ->isInstanceOf(LazyCollection::class)
49
        ;
50
    }
51
52
    /*
53
     * Test count.
54
     */
55
    public function testCount()
56
    {
57
        parent::testCount();
58
59
        $this
0 ignored issues
show
Bug introduced by
It seems like given() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
60
            ->given($collection = $this->randomCollection())
0 ignored issues
show
Bug introduced by
It seems like randomCollection() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
61
            ->when($collection->clear())
62
            ->then()
63
                ->integer($collection->count())
64
                    ->isEqualTo(0)
65
        ;
66
    }
67
68
    /*
69
     * Test getIterator.
70
     */
71
    public function testGetIterator()
72
    {
73
        parent::testGetIterator();
74
75
        $this
0 ignored issues
show
Bug introduced by
It seems like given() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
76
            ->given($collection = $this->randomCollection())
0 ignored issues
show
Bug introduced by
It seems like randomCollection() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
77
            ->when($collection->clear())
78
            ->then()
79
                ->object($collection->getIterator())
80
                    ->isInstanceOf(\Traversable::class)
81
        ;
82
    }
83
84
    /*
85
     * Test slice.
86
     */
87
    public function testSlice()
88
    {
89
        parent::testSlice();
90
91
        $this
0 ignored issues
show
Bug introduced by
It seems like given() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
92
            ->given($collection = $this->randomCollection())
0 ignored issues
show
Bug introduced by
It seems like randomCollection() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
93
            ->when($collection->clear())
94
            ->and($slicedCollection = $collection->slice(0, 10))
95
            ->then()
96
                ->collection($slicedCollection)
97
                    ->isEmpty()
98
        ;
99
    }
100
101
    /*
102
     * Test sorted.
103
     */
104
    public function testSorted()
105
    {
106
        parent::testSorted();
107
108
        $this
0 ignored issues
show
Bug introduced by
It seems like given() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
109
            ->given(
110
                $comparator = new Comparator(),
111
                $collection = $this->randomCollection()
0 ignored issues
show
Bug introduced by
It seems like randomCollection() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
112
            )
113
            ->when($collection->clear())
114
            ->and($sortedCollection = $collection->sorted($comparator))
115
            ->then
116
                ->collection($sortedCollection)
117
                    ->isSorted()
118
        ;
119
    }
120
}
121