Completed
Push — master ( 6bbd38...55e0d1 )
by Erin
10s
created

src/Interfaces/Assert/CollectionAssertTrait.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Peridot\Leo\Interfaces\Assert;
3
4
use Countable;
5
6
/**
7
 * CollectionAssertTrait contains assertions that primarily
8
 * deal with collections and countable values.
9
 *
10
 * @package Peridot\Leo\Interfaces\Assert
11
 */
12
trait CollectionAssertTrait
13
{
14
    /**
15
     * Perform a length assertion.
16
     *
17
     * @param string|array|Countable $countable
18
     * @param $length
19
     * @param string $message
20
     */
21
    public function lengthOf($countable, $length, $message = "")
22
    {
23
        $this->assertion->setActual($countable);
0 ignored issues
show
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...
24
        return $this->assertion->to->have->length($length, $message);
25
    }
26
27
    /**
28
     * Perform an inclusion assertion.
29
     *
30
     * @param array|string $haystack
31
     * @param mixed $needle
32
     * @param string $message
33
     */
34
    public function isIncluded($haystack, $needle, $message = "")
35
    {
36
        $this->assertion->setActual($haystack);
37
        return $this->assertion->to->include($needle, $message);
38
    }
39
40
    /**
41
     * Perform a negated inclusion assertion.
42
     *
43
     * @param array|string $haystack
44
     * @param mixed $needle
45
     * @param string $message
46
     */
47
    public function notInclude($haystack, $needle, $message = "")
48
    {
49
        $this->assertion->setActual($haystack);
50
        return $this->assertion->to->not->include($needle, $message);
51
    }
52
}
53