Passed
Push — master ( f90e65...c97d58 )
by Yaroslav
04:32
created

HasTablesClassesMap   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTableClassNameByType() 0 7 3
1
<?php
2
3
namespace LaraGeoData\Console\Commands;
4
5
use LaraGeoData\Database\Tables\Geonames;
6
use LaraGeoData\Database\Tables\GeoTable;
7
use LaraGeoData\Database\Tables\Postalcodes;
8
9
trait HasTablesClassesMap
10
{
11
12
    /**
13
     * @var array
14
     */
15
    protected array $classesMap = [
16
        'geonames'    => Geonames::class,
17
        'postalcodes' => Postalcodes::class,
18
    ];
19
20 14
    public function getTableClassNameByType(string $type)
21
    {
22 14
        if (!isset($this->classesMap[$type]) || !is_a($this->classesMap[$type], GeoTable::class, true)) {
23 1
            throw new \Exception("Class for type [{$type}] not found.");
24
        }
25
26 13
        return $this->classesMap[$type];
27
    }
28
}
29