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

RecordsIterateTrait::iterateRecords()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 1
b 0
f 0
nc 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
}