Completed
Branch master (cc471b)
by Vitaliy
04:22
created

InvalidDataSourceException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A forSrc() 0 17 3
1
<?php
2
3
namespace ViewComponents\Eloquent\Exception;
4
5
use InvalidArgumentException;
6
7
class InvalidDataSourceException extends InvalidArgumentException implements EloquentDataProcessingExceptionInterface
8
{
9
    public static function forSrc($src)
10
    {
11
        if (is_string($src)) {
12
            $srcName = $src;
13
        } elseif (is_object($src)) {
14
            $srcName = get_class($src) . ' instance';
15
        } else {
16
            $srcName = gettype($src);
17
        }
18
        return new static(
19
            'Invalid data source, EloquentDataProvider constructor should be used with'
20
            . ' Illuminate\Database\Eloquent\Builder instance'
21
            . ' or Illuminate\Database\Query\Builder instance'
22
            . ' or class name of target Eloquent model'
23
            . "($srcName given)."
24
        );
25
    }
26
}
27