20250622#1
This commit is contained in:
@@ -9,5 +9,5 @@ composer create-project rmphp/skeleton project-name
|
|||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer create-project rmphp/skeleton:"^4.12" project-name
|
composer create-project rmphp/skeleton:"^5.0" project-name
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Base\Application;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use ReflectionClass;
|
|
||||||
use Rmphp\Storage\Component\AbstractDataObject;
|
|
||||||
|
|
||||||
abstract class AbstractDTO extends AbstractDataObject {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array|object ...$data
|
|
||||||
* @return static
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static function fromData(array|object ...$data) : static {
|
|
||||||
$array = array_map(function($item) {
|
|
||||||
return (is_object($item)) ? get_object_vars($item) : $item;
|
|
||||||
}, $data);
|
|
||||||
return self::fromArray(array_merge(...$array));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $data
|
|
||||||
* @return static
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static function fromObject(object $data) : static {
|
|
||||||
return self::fromArray(get_object_vars($data));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
* @return static
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static function fromArray(array $data) : static {
|
|
||||||
return self::fillObject(new ReflectionClass(static::class), new static(), $data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace Base\Application;
|
|
||||||
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class DTOException extends \Exception {
|
|
||||||
|
|
||||||
public array $data;
|
|
||||||
|
|
||||||
public function __construct($message="", $code=0, array $data = [], Throwable $previous=null) {
|
|
||||||
parent::__construct($message, $code, $previous);
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"rmphp/router": "^2.0",
|
"rmphp/router": "^2.0",
|
||||||
"rmphp/session": "^1.1",
|
"rmphp/session": "^1.1",
|
||||||
"rmphp/redis": "^1.0",
|
"rmphp/redis": "^1.0",
|
||||||
"rmphp/storage": "^10.0",
|
"rmphp/storage": "^12.0",
|
||||||
"symfony/dotenv": "^6.2"
|
"symfony/dotenv": "^6.2"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
Reference in New Issue
Block a user