Passed
Push — master ( c8f01d...344099 )
by Stephen
23:45 queued 21:17
created

AssertArrayValues   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertArrayNotHasValue() 0 5 1
A assertArrayHasValue() 0 5 1
1
<?php
2
3
namespace Sfneal\Testing\Utils\Traits;
4
5
trait AssertArrayValues
6
{
7
    // todo: add tests
8
9
    /**
10
     * Assert that an array has a value.
11
     *
12
     * @param $needle
13
     * @param array $haystack
14
     */
15
    public function assertArrayHasValue($needle, array $haystack)
16
    {
17
        $this->assertTrue(
0 ignored issues
show
Bug introduced by
It seems like assertTrue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

17
        $this->/** @scrutinizer ignore-call */ 
18
               assertTrue(
Loading history...
18
            in_array($needle, array_values($haystack)),
19
            "Could not find '{$needle}' in the array ".json_encode($haystack));
20
    }
21
22
    /**
23
     * Assert that an array does not have a value.
24
     *
25
     * @param $needle
26
     * @param array $haystack
27
     */
28
    public function assertArrayNotHasValue($needle, array $haystack)
29
    {
30
        $this->assertFalse(
0 ignored issues
show
Bug introduced by
It seems like assertFalse() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

30
        $this->/** @scrutinizer ignore-call */ 
31
               assertFalse(
Loading history...
31
            in_array($needle, array_values($haystack)),
32
            "Could not find '{$needle}' in the array ".json_encode($haystack));
33
    }
34
}
35