Passed
Push — master ( e9839e...f54444 )
by Sergey
02:47
created

RecordsIterateTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 25
ccs 3
cts 5
cp 0.6
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 10 2
iterateRecords() 0 1 ?
1
<?php
2
/**
3
 * @author: Viskov Sergey
4
 * @date  : 4/12/16
5
 * @time  : 1:31 PM
6
 */
7
8
namespace LTDBeget\dns\configurator\traits;
9
10
use BadMethodCallException;
11
use InvalidArgumentException;
12
use LTDBeget\dns\configurator\zoneEntities\record\base\Record;
13
use LTDBeget\dns\enums\eRecordType;
14
15
/**
16
 * Class RecordsIterateTrait
17
 *
18
 * @package LTDBeget\dns\configurator\tarits
19
 */
20
trait RecordsIterateTrait
21
{
22
    /**
23
     * @internal
24
     * @param $name
25
     * @param $arguments
26
     * @return Record[]
27
     */
28 1
    public function __call($name, $arguments)
29
    {
30
        try {
31 1
            $type = eRecordType::get(mb_strtoupper(str_replace("iterate", "", $name)));
32
33 1
            return $this->iterateRecords($type);
34
        } catch (InvalidArgumentException $e) {
35
            throw new BadMethodCallException("Method {$name} not found");
36
        }
37
    }
38
39
    /**
40
     * @param eRecordType $type
41
     * @return mixed
42
     */
43
    abstract public function iterateRecords(eRecordType $type);
44
}