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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 9 additions & 9 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 9 additions & 9 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 4 additions & 2 deletions
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
}

0 commit comments

Comments
 (0)