AssertDatabase   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertDatabaseMissingMany() 0 4 2
A assertDatabaseHasMany() 0 4 2
1
<?php
2
3
namespace Sfneal\Testing\Utils\Traits;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
trait AssertDatabase
8
{
9
    /**
10
     * Assert that an array of records exists in the database.
11
     *
12
     * @param  Model|string  $table
13
     * @param  array[]  $records
14
     */
15
    protected function assertDatabaseHasMany($table, array $records)
16
    {
17
        foreach ($records as $data) {
18
            $this->assertDatabaseHas($table, $data);
0 ignored issues
show
Bug introduced by
The method assertDatabaseHas() does not exist on Sfneal\Testing\Utils\Traits\AssertDatabase. Did you maybe mean assertDatabaseHasMany()? ( Ignorable by Annotation )

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

18
            $this->/** @scrutinizer ignore-call */ 
19
                   assertDatabaseHas($table, $data);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
        }
20
    }
21
22
    /**
23
     * Assert that an array of records is missing in the database.
24
     *
25
     * @param  Model|string  $table
26
     * @param  array[]  $records
27
     */
28
    protected function assertDatabaseMissingMany($table, array $records)
29
    {
30
        foreach ($records as $data) {
31
            $this->assertDatabaseMissing($table, $data);
0 ignored issues
show
Bug introduced by
The method assertDatabaseMissing() does not exist on Sfneal\Testing\Utils\Traits\AssertDatabase. Did you maybe mean assertDatabaseMissingMany()? ( Ignorable by Annotation )

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

31
            $this->/** @scrutinizer ignore-call */ 
32
                   assertDatabaseMissing($table, $data);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        }
33
    }
34
}
35