Completed
Push — master ( cc6969...3d9aa5 )
by Günter
01:36
created

Contact::setAuthInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * This file is part of the php-epp2 library.
5
 *
6
 * (c) Gunter Grodotzki <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE file
9
 * that was distributed with this source code.
10
 */
11
12
namespace AfriCC\EPP\Frame\Command\Update;
13
14
use AfriCC\EPP\ContactTrait;
15
use AfriCC\EPP\Frame\Command\Update as UpdateCommand;
16
17
/**
18
 * @see http://tools.ietf.org/html/rfc5733#section-3.2.5
19
 */
20
class Contact extends UpdateCommand
21
{
22
    use ContactTrait;
23
24
    public function setId($id)
25
    {
26
        $this->appendId('contact:id', $id);
27
    }
28
29
    private function setName($mode, $name)
30
    {
31
        $this->appendName(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:name', $mode), $name);
32
    }
33
34
    private function setOrganization($mode, $org)
35
    {
36
        $this->appendOrganization(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:org', $mode), $org);
37
    }
38
39
    private function addStreet($mode, $street)
40
    {
41
        $this->appendStreet(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:addr/contact:street[]', $mode), $street);
42
    }
43
44
    private function setCity($mode, $city)
45
    {
46
        $this->appendCity(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:addr/contact:city', $mode), $city);
47
    }
48
49
    private function setProvince($mode, $sp)
50
    {
51
        $this->appendProvince(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:addr/contact:sp', $mode), $sp);
52
    }
53
54
    private function setPostalCode($mode, $pc)
55
    {
56
        $this->appendPostalCode(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:addr/contact:pc', $mode), $pc);
57
    }
58
59
    private function setCountryCode($mode, $cc)
60
    {
61
        $this->appendCountryCode(sprintf('contact:%s/contact:postalInfo[@type=\'%%s\']/contact:addr/contact:cc', $mode), $cc);
62
    }
63
64
    private function setVoice($mode, $voice, $extension = null)
65
    {
66
        $this->appendVoice(sprintf('contact:%s/contact:voice', $mode), $voice, $extension);
67
    }
68
69
    private function setFax($mode, $fax, $extension = null)
70
    {
71
        $this->appendFax(sprintf('contact:%s/contact:fax', $mode), $fax, $extension);
72
    }
73
74
    private function setEmail($mode, $email)
75
    {
76
        $this->appendEmail(sprintf('contact:%s/contact:email', $mode), $email);
77
    }
78
79
    private function setAuthInfo($mode, $pw = null)
80
    {
81
        return $this->appendAuthInfo(sprintf('contact:%s/contact:authInfo/contact:pw', $mode), $pw);
82
    }
83
84
    private function addDisclose($mode, $value, $flag = 0)
85
    {
86
        $this->appendDisclose(sprintf('contact:%s/contact:disclose[@flag=\'%d\']/contact:%s', $mode, $flag, $value));
87
    }
88
89
    private function setStatus($mode, $status)
90
    {
91
        $this->set(sprintf('contact:%s/contact:status[@s=\'%s\']', $mode, $status));
92
    }
93
94
    public function __call($name, $arguments)
95
    {
96
        if (strpos($name, 'add') === 0) {
97
            array_unshift($arguments, 'add');
98
            $method_name = substr($name, 3);
99
        } elseif (strpos($name, 'remove') === 0) {
100
            array_unshift($arguments, 'rem');
101
            $method_name = substr($name, 6);
102
        } elseif (strpos($name, 'change') === 0) {
103
            array_unshift($arguments, 'chg');
104
            $method_name = substr($name, 6);
105
        } else {
106
            return;
107
        }
108
109
        if (strpos($method_name, 'Add') === 0) {
110
            $method_name = lcfirst($method_name);
111
        } else {
112
            $method_name = 'set' . $method_name;
113
        }
114
115
        if (is_callable([$this, $method_name])) {
116
            return call_user_func_array([$this, $method_name], $arguments);
117
        }
118
    }
119
}
120