-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update RouteAction class and ActionType sub-classes
This revision makes significant updates to the RouteAction class and introduces ActionType sub-classes. It changes the setState method to work with these new classes and updates the toArray method accordingly. Additionally, this commit improved the route block test to include ActionType instances instead of raw data and restructured RouteActionTest to use these new ActionType classes. Most property values in the RouteAction class are now instances of ActionType subclasses, such as PassAction, ProxyAction, ShareAction, and ReturnAction.
- Loading branch information
1 parent
2a032d5
commit cf4f1d6
Showing
11 changed files
with
644 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace UnitPhpSdk\Config\Routes\ActionType; | ||
|
||
use UnitPhpSdk\Contracts\Arrayable; | ||
|
||
class PassAction implements Arrayable | ||
{ | ||
public function __construct( | ||
private string $pass | ||
) | ||
{ | ||
$this->setPass($pass); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPass(): string | ||
{ | ||
return $this->pass; | ||
} | ||
|
||
/** | ||
* @param string $pass | ||
*/ | ||
public function setPass(string $pass): void | ||
{ | ||
$this->pass = $pass; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'pass' => $this->getPass() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace UnitPhpSdk\Config\Routes\ActionType; | ||
|
||
use UnitPhpSdk\Contracts\Arrayable; | ||
|
||
class ProxyAction implements Arrayable | ||
{ | ||
public function __construct( | ||
private string $proxy | ||
) | ||
{ | ||
$this->setProxy($proxy); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getProxy(): string | ||
{ | ||
return $this->proxy; | ||
} | ||
|
||
/** | ||
* @param string $proxy | ||
*/ | ||
public function setProxy(string $proxy): void | ||
{ | ||
$this->proxy = $proxy; | ||
} | ||
|
||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'proxy' => $this->getProxy() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace UnitPhpSdk\Config\Routes\ActionType; | ||
|
||
use OutOfRangeException; | ||
use UnitPhpSdk\Contracts\Arrayable; | ||
|
||
class ReturnAction implements Arrayable | ||
{ | ||
public function __construct( | ||
|
||
/** | ||
* HTTP status code with a context-dependent redirect location. | ||
* Integer (000–999); defines the HTTP response status code to be returned. | ||
*/ | ||
private int $return, | ||
|
||
/** | ||
* String URI; used if the return value implies redirection. | ||
* | ||
* @var string | ||
*/ | ||
private string $location = '' | ||
) { | ||
if ($return > 999 || $return < 0) { | ||
throw new OutOfRangeException('Return must be between 0 and 999'); | ||
} | ||
|
||
if (!empty($location)) { | ||
$this->setLocation($location); | ||
} | ||
} | ||
|
||
/** | ||
* @param int $return | ||
*/ | ||
public function setReturn(int $return): void | ||
{ | ||
$this->return = $return; | ||
} | ||
|
||
/** | ||
* @param string $location | ||
*/ | ||
public function setLocation(string $location): void | ||
{ | ||
$this->location = $location; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getReturn(): int | ||
{ | ||
return $this->return; | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLocation(): string | ||
{ | ||
return $this->location; | ||
} | ||
|
||
/** | ||
* Converts the object to an array. | ||
* | ||
* @return array The converted array representation of the object. | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'return' => $this->return, | ||
'location' => $this->location, | ||
]; | ||
} | ||
} |
Oops, something went wrong.