Skip to content

Commit fc561b2

Browse files
authored
Merge pull request #71 from svandervlugt/get_limits
Add Webspace getLimits
2 parents 9304901 + 6ea0f11 commit fc561b2

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

src/Api/Operator/Webspace.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public function getPhpSettings($field, $value)
4343
return new Struct\PhpSettings($response);
4444
}
4545

46+
/**
47+
* @param string $field
48+
* @param integer|string $value
49+
* @return Struct\Limits
50+
*/
51+
public function getLimits($field, $value)
52+
{
53+
$items = $this->_getItems(Struct\Limits::class, 'limits', $field, $value);
54+
return reset($items);
55+
}
56+
4657
/**
4758
* @param array $properties
4859
* @param array|null $hostingProperties
@@ -119,5 +130,4 @@ public function getDiskUsage($field, $value)
119130
$items = $this->_getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value);
120131
return reset($items);
121132
}
122-
123133
}

src/Api/Struct/Webspace/Limit.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
// Copyright 1999-2019. Plesk International GmbH.
3+
4+
namespace PleskX\Api\Struct\Webspace;
5+
6+
class Limit extends \PleskX\Api\Struct
7+
{
8+
/** @var string */
9+
public $name;
10+
11+
/** @var string */
12+
public $value;
13+
14+
public function __construct($apiResponse)
15+
{
16+
$this->_initScalarProperties($apiResponse, [
17+
'name',
18+
'value',
19+
]);
20+
}
21+
}

src/Api/Struct/Webspace/Limits.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
// Copyright 1999-2019. Plesk International GmbH.
3+
4+
namespace PleskX\Api\Struct\Webspace;
5+
6+
class Limits extends \PleskX\Api\Struct
7+
{
8+
/** @var string */
9+
public $overuse;
10+
11+
/** @var array */
12+
public $limits;
13+
14+
public function __construct($apiResponse)
15+
{
16+
$this->_initScalarProperties($apiResponse, ['overuse']);
17+
$this->limits = [];
18+
19+
foreach ($apiResponse->limit as $limit) {
20+
$this->limits[(string) $limit->name] = new Limit($limit);
21+
}
22+
}
23+
}

tests/WebspaceTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ public function testGetPhpSettings()
5151
static::$_client->webspace()->delete('id', $webspace->id);
5252
}
5353

54+
public function testGetLimits()
55+
{
56+
$webspace = static::_createWebspace();
57+
$limits = static::$_client->webspace()->getLimits('id', $webspace->id);
58+
59+
$this->assertIsArray($limits->limits);
60+
$this->assertNotEmpty($limits->limits);
61+
62+
static::$_client->webspace()->delete('id', $webspace->id);
63+
}
64+
5465
public function testCreateWebspace()
5566
{
5667
$webspace = static::_createWebspace();

0 commit comments

Comments
 (0)