Skip to content

Commit 7cada75

Browse files
Merge pull request #6 from shellrent/fix_client
Fix namespaces for AbstractStruct
2 parents 0bdc934 + bb97190 commit 7cada75

20 files changed

+79
-55
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
.idea
44
/nbproject/
55
/.phpunit.result.cache
6-
/coverage.xml
6+
/coverage.xml
7+
composer.phar
8+

src/Api/Operator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ protected function getItems($structClass, $infoTag, $field = null, $value = null
112112
*/
113113
protected function _getId( $field = null, $value = null )
114114
{
115-
$packet = $this->_client->getPacket();
116-
$getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
115+
$packet = $this->client->getPacket();
116+
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
117117

118118
$filterTag = $getTag->addChild('filter');
119119
if (!is_null($field)) {
@@ -122,7 +122,7 @@ protected function _getId( $field = null, $value = null )
122122

123123
$getTag->addChild('dataset');
124124

125-
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
125+
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
126126

127127
$ids = [];
128128
foreach ($response->xpath('//result') as $xmlResult) {

src/Api/Operator/Certificate.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public function generate(array $properties): Struct\Info
3030
*/
3131
public function getAll($field, $value )
3232
{
33-
$packet = $this->_client->getPacket();
34-
$getTag = $packet->addChild($this->_wrapperTag)->addChild('get-pool');
33+
$packet = $this->client->getPacket();
34+
$getTag = $packet->addChild($this->wrapperTag)->addChild('get-pool');
3535

3636
$filterTag = $getTag->addChild('filter');
3737
$filterTag->addChild($field, $value);
3838

39-
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
39+
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
4040

4141
$items = [];
4242
foreach ($response->xpath('//result/certificates') as $xmlResult) {
@@ -54,8 +54,8 @@ public function getAll($field, $value )
5454
*/
5555
public function install($properties)
5656
{
57-
$packet = $this->_client->getPacket();
58-
$install = $packet->addChild($this->_wrapperTag)->addChild('install');
57+
$packet = $this->client->getPacket();
58+
$install = $packet->addChild($this->wrapperTag)->addChild('install');
5959

6060
foreach ($properties as $name => $value) {
6161
if ($name == 'content') {
@@ -71,7 +71,7 @@ public function install($properties)
7171
$install->addChild($name, $value);
7272
}
7373

74-
$response = $this->_client->request($packet);
74+
$response = $this->client->request($packet);
7575
return new Struct\InstallInfo($response);
7676
}
7777

@@ -82,8 +82,8 @@ public function install($properties)
8282
*/
8383
public function remove($properties)
8484
{
85-
$packet = $this->_client->getPacket();
86-
$removeNode = $packet->addChild($this->_wrapperTag)->addChild('remove');
85+
$packet = $this->client->getPacket();
86+
$removeNode = $packet->addChild($this->wrapperTag)->addChild('remove');
8787

8888
foreach ($properties as $key => $value) {
8989
if( $key == 'filter' ) {
@@ -99,7 +99,7 @@ public function remove($properties)
9999
$removeNode->addChild($key, $value);
100100
}
101101

102-
$response = $this->_client->request($packet);
102+
$response = $this->client->request($packet);
103103

104104
return new Struct\RemoveInfo( $response );
105105
}

src/Api/Operator/FtpUser.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class FtpUser extends \PleskX\Api\Operator {
1414
* @return \PleskX\Api\XmlResponse
1515
*/
1616
private function _get($command, $field, $value) {
17-
$packet = $this->_client->getPacket();
18-
$getTag = $packet->addChild($this->_wrapperTag)->addChild($command);
17+
$packet = $this->client->getPacket();
18+
$getTag = $packet->addChild($this->wrapperTag)->addChild($command);
1919

2020
$filterTag = $getTag->addChild('filter');
2121
if (!is_null($field)) {
2222
$filterTag->addChild($field, $value);
2323
}
2424

25-
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
25+
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
2626
return $response;
2727
}
2828

@@ -32,16 +32,16 @@ private function _get($command, $field, $value) {
3232
* @param string $newPassword
3333
*/
3434
public function updateFtpPassword( $ftpUser, $newPassword ) {
35-
$packet = $this->_client->getPacket();
36-
$set = $packet->addChild( $this->_wrapperTag )->addChild( 'set' );
35+
$packet = $this->client->getPacket();
36+
$set = $packet->addChild( $this->wrapperTag )->addChild( 'set' );
3737

3838
$filter = $set->addChild( 'filter' );
3939
$filter->addChild( 'name', $ftpUser );
4040

4141
$values = $set->addChild( 'values' );
4242
$values->addChild( 'password', $newPassword );
4343

44-
$this->_client->request($packet);
44+
$this->client->request($packet);
4545
}
4646

4747

src/Api/Operator/PhpHandler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public function getAll($field = null, $value = null): array
6363
* @return Struct\GeneralInfo[]
6464
*/
6565
public function getHandler( $handlerId ) {
66-
$packet = $this->_client->getPacket();
67-
$getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
66+
$packet = $this->client->getPacket();
67+
$getTag = $packet->addChild($this->wrapperTag)->addChild('get');
6868

6969
$filterTag = $getTag->addChild('filter');
7070
$filterTag->addChild('id', $handlerId);
71-
$response = $this->_client->request( $packet );
71+
$response = $this->client->request( $packet );
7272

7373
$item = [];
7474

src/Api/Operator/Server.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ private function getInfo(string $operation): XmlResponse
147147
* @return Struct\LicenseInfo
148148
*/
149149
public function getLicenseInfo() {
150-
$packet = $this->_client->getPacket();
151-
$packet->addChild( $this->_wrapperTag )->addChild( 'get' )->addChild( 'key' );
150+
$packet = $this->client->getPacket();
151+
$packet->addChild( $this->wrapperTag )->addChild( 'get' )->addChild( 'key' );
152152

153-
$response = $this->_client->request( $packet );
153+
$response = $this->client->request( $packet );
154154

155155
return new Struct\LicenseInfo( $response );
156156
}
@@ -161,10 +161,10 @@ public function getLicenseInfo() {
161161
* @return Struct\LicenseAdditionalInfo
162162
*/
163163
public function getAdditionalLicensesInfo() {
164-
$packet = $this->_client->getPacket();
165-
$packet->addChild( $this->_wrapperTag )->addChild( 'get_additional_key' );
164+
$packet = $this->client->getPacket();
165+
$packet->addChild( $this->wrapperTag )->addChild( 'get_additional_key' );
166166

167-
$response = new Struct\LicenseAdditionalInfo( $this->_client->request( $packet ) );
167+
$response = new Struct\LicenseAdditionalInfo( $this->client->request( $packet ) );
168168

169169
if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) {
170170
throw new Exception( $response->error_message, $response->error_code );
@@ -181,8 +181,8 @@ public function getAdditionalLicensesInfo() {
181181
* @return Struct\LicenseInstall
182182
*/
183183
public function installLicense( $activationCode, $isAdditionalLicense = false ) {
184-
$packet = $this->_client->getPacket();
185-
$server = $packet->addChild( $this->_wrapperTag );
184+
$packet = $this->client->getPacket();
185+
$server = $packet->addChild( $this->wrapperTag );
186186
$licInstall = $server->addChild( 'lic_install' );
187187

188188
$licInstall->addChild( 'activation-code', $activationCode );
@@ -191,7 +191,7 @@ public function installLicense( $activationCode, $isAdditionalLicense = false )
191191
$licInstall->addChild( 'additional_key' );
192192
}
193193

194-
$response = new Struct\LicenseInstall( $this->_client->request( $packet ) );
194+
$response = new Struct\LicenseInstall( $this->client->request( $packet ) );
195195

196196
if( !is_null( $response->error_code ) or !empty( $response->error_message ) ) {
197197
throw new Exception( $response->error_message, $response->error_code );

src/Api/Operator/Site.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,6 @@ public function getAll(): array
9797
*/
9898
public function getAllWebspaceInfos()
9999
{
100-
return $this->_getItems(Struct\CompleteGeneralInfo::class, 'gen_info');
100+
return $this->getItems(Struct\CompleteGeneralInfo::class, 'gen_info');
101101
}
102102
}

src/Api/Struct/Certificate/InstallInfo.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
namespace PleskX\Api\Struct\Certificate;
55

6-
class InstallInfo extends \PleskX\Api\Struct
6+
use PleskX\Api\AbstractStruct;
7+
8+
class InstallInfo extends AbstractStruct
79
{
810
/** @var string */
911
public $status;
1012

1113
public function __construct($apiResponse)
1214
{
13-
$this->_initScalarProperties($apiResponse, [
15+
$this->initScalarProperties($apiResponse, [
1416
'status',
1517
]);
1618
}

src/Api/Struct/Certificate/PoolInfo.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
namespace PleskX\Api\Struct\Certificate;
55

6-
class PoolInfo extends \PleskX\Api\Struct
6+
use PleskX\Api\AbstractStruct;
7+
8+
class PoolInfo extends AbstractStruct
79
{
810
/** @var string */
911
public $name;
1012

1113
public function __construct($apiResponse)
1214
{
13-
$this->_initScalarProperties($apiResponse, [
15+
$this->initScalarProperties($apiResponse, [
1416
['name' => 'name'],
1517
]);
1618
}

src/Api/Struct/Certificate/RemoveInfo.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
namespace PleskX\Api\Struct\Certificate;
55

6-
class RemoveInfo extends \PleskX\Api\Struct
6+
use PleskX\Api\AbstractStruct;
7+
8+
class RemoveInfo extends AbstractStruct
79
{
810
/** @var string */
911
public $status;
1012

1113
public function __construct($apiResponse)
1214
{
13-
$this->_initScalarProperties($apiResponse, [
15+
$this->initScalarProperties($apiResponse, [
1416
'status',
1517
]);
1618
}

src/Api/Struct/FtpUser/Info.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace PleskX\Api\Struct\FtpUser;
44

5-
class Info extends \PleskX\Api\Struct
5+
use PleskX\Api\AbstractStruct;
6+
7+
class Info extends AbstractStruct
68
{
79

810
/** @var integer */
@@ -19,7 +21,7 @@ class Info extends \PleskX\Api\Struct
1921

2022

2123
public function __construct( $apiResponse ) {
22-
$this->_initScalarProperties($apiResponse, [
24+
$this->initScalarProperties($apiResponse, [
2325
'id',
2426
'name',
2527
'home',

src/Api/Struct/Server/License/keyInfo.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace PleskX\Api\Struct\Server\License;
44

5+
use PleskX\Api\AbstractStruct;
56
use PleskX\Api\Struct\Server\LicensePropertyInfo;
67

78

89
/**
910
* Struttura dati per le informazioni su una licenza
1011
*/
11-
class keyInfo extends \PleskX\Api\Struct {
12+
class keyInfo extends AbstractStruct {
1213

1314
/** @var \PleskX\Api\Struct\Server\LicensePropertyInfo[] Collezione di proprietà della licenza */
1415
public $properties;

src/Api/Struct/Server/LicenseAdditional/keyAdditionalInfo.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace PleskX\Api\Struct\Server\LicenseAdditional;
44

5+
use PleskX\Api\AbstractStruct;
56
use PleskX\Api\Struct\Server\LicensePropertyInfo;
67

78

89
/**
910
* Struttura dati per le informazioni su una licenza
1011
*/
11-
class keyAdditionalInfo extends \PleskX\Api\Struct {
12+
class keyAdditionalInfo extends AbstractStruct {
1213

1314
/** @var string Numero completo della licenza */
1415
public $key_number;
@@ -30,7 +31,7 @@ class keyAdditionalInfo extends \PleskX\Api\Struct {
3031
* @param \SimpleXMLElement $apiResponse
3132
*/
3233
public function __construct( $apiResponse ) {
33-
$this->_initScalarProperties( $apiResponse, [
34+
$this->initScalarProperties( $apiResponse, [
3435
['number' => 'key_number'],
3536
['name' => 'full_name'],
3637
['active' => 'active'],

src/Api/Struct/Server/LicenseAdditionalInfo.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace PleskX\Api\Struct\Server;
44

5+
use PleskX\Api\AbstractStruct;
56
use PleskX\Api\Struct\Server\LicenseAdditional\keyAdditionalInfo;
67

78

89
/**
910
* Struttura dati per le informazioni su una licenza aggiuntiva
1011
*/
11-
class LicenseAdditionalInfo extends \PleskX\Api\Struct {
12+
class LicenseAdditionalInfo extends AbstractStruct {
1213

1314
/** @var string Stato della licenza */
1415
public $status;
@@ -19,15 +20,15 @@ class LicenseAdditionalInfo extends \PleskX\Api\Struct {
1920
/** @var string Messaggio di errore in caso di fallimento della richiesta */
2021
public $error_message;
2122

22-
/** @var \PleskX\Api\Struct\Server\License\keyAdditionalInfo Licenza aggiuntiva */
23+
/** @var $key \PleskX\Api\Struct\Server\LicenseAdditional\keyAdditionalInfo */
2324
public $key;
2425

2526

2627
/**
2728
* @param \SimpleXMLElement $apiResponse Oggetto xml a partire da <result>
2829
*/
2930
public function __construct( $apiResponse ) {
30-
$this->_initScalarProperties( $apiResponse, [
31+
$this->initScalarProperties( $apiResponse, [
3132
'status',
3233
]);
3334

src/Api/Struct/Server/LicenseInfo.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace PleskX\Api\Struct\Server;
44

5+
use PleskX\Api\AbstractStruct;
56
use PleskX\Api\Struct\Server\License\keyInfo;
67

78

89
/**
910
* Struttura dati per le informazioni sulla licenza installata
1011
*/
11-
class LicenseInfo extends \PleskX\Api\Struct {
12+
class LicenseInfo extends AbstractStruct {
1213

1314
/** @var string Stato della licenza */
1415
public $status;
@@ -21,7 +22,7 @@ class LicenseInfo extends \PleskX\Api\Struct {
2122
* @param \SimpleXMLElement $apiResponse Oggetto xml a partire da <result>
2223
*/
2324
public function __construct( $apiResponse ) {
24-
$this->_initScalarProperties( $apiResponse, [
25+
$this->initScalarProperties( $apiResponse, [
2526
'status',
2627
]);
2728

src/Api/Struct/Server/LicenseInstall.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
namespace PleskX\Api\Struct\Server;
44

55

6+
use PleskX\Api\AbstractStruct;
7+
68
/**
79
* Struttura dati per la response di installazione licenza principale o aggiuntiva
810
*/
9-
class LicenseInstall extends \PleskX\Api\Struct {
11+
class LicenseInstall extends AbstractStruct {
1012

1113
/** @var string Stato della licenza */
1214
public $status;
@@ -22,7 +24,7 @@ class LicenseInstall extends \PleskX\Api\Struct {
2224
* @param \SimpleXMLElement $apiResponse
2325
*/
2426
public function __construct( $apiResponse ) {
25-
$this->_initScalarProperties( $apiResponse, [
27+
$this->initScalarProperties( $apiResponse, [
2628
[ 'status' => 'status'],
2729
]);
2830

0 commit comments

Comments
 (0)