Completed
Push — master ( ee041c...22b621 )
by Joschi
04:52
created

Domain::loadAccount()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * admin
5
 *
6
 * @category    Tollwerk
7
 * @package     Tollwerk\Admin
8
 * @subpackage  Tollwerk\Admin\Ports\Facade
9
 * @author      Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright   Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license     http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Tollwerk\Admin\Ports\Facade;
38
39
use \Tollwerk\Admin\Domain\Domain\Domain as DomainDomain;
40
use Tollwerk\Admin\Infrastructure\App;
41
use Tollwerk\Admin\Infrastructure\Facade\AbstractFacade;
42
43
/**
44
 * Domain facade
45
 *
46
 * @package Tollwerk\Admin
47
 * @subpackage Tollwerk\Admin\Ports
48
 */
49
class Domain extends AbstractFacade
50
{
51
    /**
52
     * Create and add a domain to an account
53
     *
54
     * @param string $account Account name
55
     * @param string $domain Domain name
56
     * @return boolean Success
57
     * @throws \Exception If the domain couldn't be created
58
     */
59
    public static function create($account, $domain)
60
    {
61
        // Get the account to operate on
62
        $account = self::loadAccount($account);
63
64
        // Check if the domain already exists and is unassigned
65
        try {
66
            $domain = App::getDomainService()->loadUnassigned($domain, $account);
67
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
68
        } catch (\RuntimeException $e) {
69
            // If the domain already exists but is assigned or belongs to another account: Error
70
            if ($e->getCode() != 1475915909) {
71
                throw $e;
72
            }
73
74
            // Create the domain
75
            $domain = App::getDomainService()->create($domain, $account);
76
        }
77
78
        return $domain instanceof DomainDomain;
79
    }
80
81
    /**
82
     * Delete a domain
83
     *
84
     * @param string $domain Domain name
0 ignored issues
show
Bug introduced by
There is no parameter named $domain. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
85
     * @return boolean Success
86
     */
87
    public static function delete($name)
88
    {
89
        return App::getDomainService()->delete($name) instanceof DomainDomain;
90
    }
91
92
    /**
93
     * Enable a domain
94
     *
95
     * @param string $domain Domain name
0 ignored issues
show
Bug introduced by
There is no parameter named $domain. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
96
     * @return boolean Success
97
     */
98
    public static function enable($name)
99
    {
100
        return App::getDomainService()->enable($name) instanceof DomainDomain;
101
    }
102
103
    /**
104
     * Disable a domain
105
     *
106
     * @param string $domain Domain name
0 ignored issues
show
Bug introduced by
There is no parameter named $domain. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
107
     * @return boolean Success
108
     */
109
    public static function disable($name)
110
    {
111
        return App::getDomainService()->disable($name) instanceof DomainDomain;
112
    }
113
114
    /**
115
     * Enable a domain wildcard
116
     *
117
     * @param string $domain Domain name
0 ignored issues
show
Bug introduced by
There is no parameter named $domain. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
118
     * @return boolean Success
119
     */
120
    public static function enableWildcard($name)
121
    {
122
        return App::getDomainService()->enableWildcard($name) instanceof DomainDomain;
123
    }
124
125
    /**
126
     * Disable a domain wildcard
127
     *
128
     * @param string $domain Domain name
0 ignored issues
show
Bug introduced by
There is no parameter named $domain. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
129
     * @return boolean Success
130
     */
131
    public static function disableWildcard($name)
132
    {
133
        return App::getDomainService()->disableWildcard($name) instanceof DomainDomain;
134
    }
135
}
136