Completed
Pull Request — master (#65)
by
unknown
01:15
created

Contact::setConsentForPublishing()   A

Complexity

Conditions 2
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 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the php-epp2 library.
5
 *
6
 * (c) Riccardo Bessone <[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\Extension\NicIT\Create;
13
14
use AfriCC\EPP\ExtensionInterface as Extension;
15
use AfriCC\EPP\Frame\Command\Create\Contact as ContactCreate;
16
use AfriCC\EPP\Validator;
17
18
class Contact extends ContactCreate implements Extension
19
{
20
    protected $extension = 'extcon';
21
    protected $extension_xmlns = 'http://www.nic.it/ITNIC-EPP/extcon-1.0';
22
23
    protected static $entityTypes = [
24
        1, // Italian and foreign natural persons
25
        2, // Companies/one man companie
26
        3, // Freelance workers/professionals
27
        4, // Non-profit organizations
28
        5, // Public organizations
29
        6, // Other subjects
30
        7, // Foreigners who match 2-6
31
    ];
32
33
    public function getExtensionNamespace()
34
    {
35
        return $this->extension_xmlns;
36
    }
37
38
    public function setConsentForPublishing($consent = false)
39
    {
40
        $this->set('//epp:epp/epp:command/epp:extension/extcon:create/extcon:consentForPublishing', $consent ? 'true' : 'false');
41
    }
42
43
    public function setRegistrant($entityType, $nationalityCode = '', $regCode = '')
44
    {
45
        if (!in_array($entityType, self::$entityTypes)) {
46
            throw new Exception(sprintf('the entity type: \'%s\' is invalid', $entityType));
47
        }
48
        $this->set('//epp:epp/epp:command/epp:extension/extcon:create/extcon:registrant/extcon:entityType', $entityType);
49
50
        if ($nationalityCode != '' && !Validator::isCountryCode($nationalityCode)) {
51
            throw new Exception(sprintf('the country-code: \'%s\' is unknown', $nationalityCode));
52
        }
53
        $this->set('//epp:epp/epp:command/epp:extension/extcon:create/extcon:registrant/extcon:nationalityCode', $nationalityCode);
54
55
        if ($regCode != '') {
56
            $this->set('//epp:epp/epp:command/epp:extension/extcon:create/extcon:registrant/extcon:regCode', $regCode);
57
        }
58
    }
59
}
60