CollectionAssertTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 44
rs 10
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A lengthOf() 0 6 1
A isIncluded() 0 6 1
A notInclude() 0 6 1
1
<?php
2
3
namespace Peridot\Leo\Interfaces\Assert;
4
5
use Countable;
6
7
/**
8
 * CollectionAssertTrait contains assertions that primarily
9
 * deal with collections and countable values.
10
 *
11
 * @package Peridot\Leo\Interfaces\Assert
12
 */
13
trait CollectionAssertTrait
14
{
15
    /**
16
     * Perform a length assertion.
17
     *
18
     * @param string|array|Countable $countable
19
     * @param $length
20
     * @param string $message
21
     */
22
    public function lengthOf($countable, $length, $message = '')
23
    {
24
        $this->assertion->setActual($countable);
0 ignored issues
show
Bug introduced by
The property assertion does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
26
        return $this->assertion->to->have->length($length, $message);
27
    }
28
29
    /**
30
     * Perform an inclusion assertion.
31
     *
32
     * @param array|string $haystack
33
     * @param mixed        $needle
34
     * @param string       $message
35
     */
36
    public function isIncluded($haystack, $needle, $message = '')
37
    {
38
        $this->assertion->setActual($haystack);
39
40
        return $this->assertion->to->include($needle, $message);
41
    }
42
43
    /**
44
     * Perform a negated inclusion assertion.
45
     *
46
     * @param array|string $haystack
47
     * @param mixed        $needle
48
     * @param string       $message
49
     */
50
    public function notInclude($haystack, $needle, $message = '')
51
    {
52
        $this->assertion->setActual($haystack);
53
54
        return $this->assertion->to->not->include($needle, $message);
55
    }
56
}
57