Switch from stdClass to object casting

This commit is contained in:
Kleis Auke Wolthuizen
2017-11-21 17:35:01 +01:00
parent 4f3f82b1ba
commit a4224265d8
10 changed files with 27 additions and 68 deletions

View File

@@ -14,13 +14,15 @@ class PageRulesTargets implements Configurations
public function __construct(string $queryUrl)
{
$target = new \stdClass();
$target->target = 'url';
$target->constraint = new \stdClass();
$target->constraint->operator = 'matches';
$target->constraint->value = $queryUrl;
$this->targets = [$target];
$this->targets = [
(object)[
'target' => 'url',
'constraint' => (object)[
'operator' => 'matches',
'value' => $queryUrl
]
]
];
}
public function getArray(): array

View File

@@ -14,9 +14,7 @@ class UARules implements Configurations
public function addUA(string $value)
{
$object = new \stdClass();
$object->target = 'ua';
$object->value = $value;
$object = (object)['target' => 'ua', 'value' => $value];
array_push($this->configs, $object);
}

View File

@@ -14,18 +14,14 @@ class ZoneLockdown implements Configurations
public function addIP(string $value)
{
$object = new \stdClass();
$object->target = 'ip';
$object->value = $value;
$object = (object)['target' => 'ip', 'value' => $value];
array_push($this->configs, $object);
}
public function addIPRange(string $value)
{
$object = new \stdClass();
$object->target = 'ip_range';
$object->value = $value;
$object = (object)['target' => 'ip_range', 'value' => $value];
array_push($this->configs, $object);
}