Completed
Pull Request — master (#79)
by
unknown
04:46
created

Contact   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

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