Completed
Pull Request — master (#29)
by Dominik
02:32 queued 47s
created

SiteAlias   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 19 5
1
<?php
2
// Copyright 1999-2016. Parallels IP Holdings GmbH.
3
4
namespace PleskX\Api\Operator;
5
6
use PleskX\Api\Struct\SiteAlias as Struct;
7
8
class SiteAlias extends \PleskX\Api\Operator
9
{
10
    /**
11
     * @param array $properties
12
     * @param array $preferences
13
     * @return Struct\Info
14
     */
15
    public function create(array $properties, array $preferences = [])
16
    {
17
        $packet = $this->_client->getPacket();
18
        $info = $packet->addChild($this->_wrapperTag)->addChild('create');
19
20
        if (count($preferences) > 0) {
21
            $prefs = $info->addChild('pref');
22
23
            foreach ($preferences as $key => $value) {
24
                $prefs->addChild($key, is_bool($value) ? ($value ? 1 : 0) : $value);
25
            }
26
        }
27
28
        $info->addChild('site-id', $properties['site-id']);
29
        $info->addChild('name', $properties['name']);
30
31
        $response = $this->_client->request($packet);
32
        return new Struct\Info($response);
33
    }
34
35
}
36