Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d1f1b79ba | |||
| 393f37577d | |||
| 584285b92c | |||
| ed2a41a139 | |||
| 89c6d0c814 | |||
| 67a2ea3e1d |
@@ -25,7 +25,11 @@
|
||||
"php": "~8.4"
|
||||
},
|
||||
"suggest": {
|
||||
"mirzaev/baza": "Baza database"
|
||||
"mirzaev/baza": "Baza database",
|
||||
"mirzaev/pot": "Template for projects",
|
||||
"mirzaev/files": "Easy working with files",
|
||||
"mirzaev/languages": "Easy languages integration",
|
||||
"mirzaev/currencies": "Easy currencies integration"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -34,7 +34,7 @@ use Closure as closure,
|
||||
* @param model $model An instance of the model
|
||||
* @param router $router An instance of the router
|
||||
*
|
||||
* @mathod void __construct(?string $namespace) Constructor
|
||||
* @method void __construct(?string $namespace) Constructor
|
||||
* @method void __destruct() Destructor
|
||||
* @method string|null start() Initialize request by environment and handle it
|
||||
* @method string|null request(request $request, array $parameters = []) Handle request
|
||||
|
||||
@@ -408,9 +408,6 @@ final class request
|
||||
// Exit (false)
|
||||
throw new exception_argument('Failed to validate JSON from the input buffer', status::unprocessable_content->value);
|
||||
}
|
||||
|
||||
// Writing parameters from environment into the property
|
||||
$this->parameters = $_POST ?? [];
|
||||
} else if ($this->method === method::post) {
|
||||
// POST method
|
||||
|
||||
|
||||
@@ -114,6 +114,18 @@ final class route
|
||||
get => $this->options ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters
|
||||
*
|
||||
* @see https://wiki.php.net/rfc/property-hooks (find a table about backed and virtual hooks)
|
||||
*
|
||||
* @var array $parameters Arguments for the $this->method (will be concatenated together with generated request parameters)
|
||||
*/
|
||||
public array $variables = [] {
|
||||
// Read
|
||||
&get => $this->variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace mirzaev\minimal\traits;
|
||||
use mirzaev\minimal\http\enumerations\status;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
use Exception as exception,
|
||||
DomainException as exception_domain;
|
||||
|
||||
/**
|
||||
* Trait of magical methods
|
||||
@@ -28,6 +29,8 @@ trait magic
|
||||
/**
|
||||
* Write property
|
||||
*
|
||||
* @throws exception_domain Not found the proprty
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
* @param mixed $value Value of the property
|
||||
*
|
||||
@@ -35,14 +38,24 @@ trait magic
|
||||
*/
|
||||
public function __set(string $name, mixed $value = null): void
|
||||
{
|
||||
match ($name) {
|
||||
default => throw new exception('Failed to find property: ' . static::class . "::\$$name", status::not_found->value)
|
||||
};
|
||||
if (property_exists(static, $name)) {
|
||||
// Exist the property
|
||||
|
||||
// Writing the property
|
||||
$this->{$name} = $value;
|
||||
} else {
|
||||
// Not exist the property
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_domain('Not found the property: ' . static::class . "::\$$name", status::not_found->value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read property
|
||||
*
|
||||
* @throws exception_domain Not found the property
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return mixed Value of the property
|
||||
@@ -50,7 +63,7 @@ trait magic
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
return match ($name) {
|
||||
default => throw new exception('Failed to find property: ' . static::class . "::\$$name", status::not_found->value)
|
||||
default => throw new exception_domain('Not found the property: ' . static::class . "::\$$name", status::not_found->value)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user