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

RecordsIterateTrait::__call()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
ccs 3
cts 5
cp 0.6
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 6
nc 3
nop 2
crap 2.2559
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
}