refac: 변경한 DTO에 따라 코드 수정
- Spatie/DataTransferObject 대비
- MapFrom,MapTo -> RawName
- Strict -> 항상
- 심지어 raw type도 더 까다롭게
- array에 MapConverter 적용
- NullIsUndefined 적용
- 빈 nullable arg자리에 null 강제 지정
- Vue3에 v-model.number 지정
- input type="number" 기준
This commit is contained in:
@@ -4,6 +4,7 @@ use sammo\DTO\Attr\Convert;
|
||||
use sammo\DTO\DTO;
|
||||
use sammo\DTO\Attr\JsonString;
|
||||
use sammo\DTO\Attr\NullIsUndefined;
|
||||
use sammo\DTO\Attr\RawName;
|
||||
use sammo\DTO\Converter\ArrayConverter;
|
||||
use sammo\DTO\Converter\Converter;
|
||||
use sammo\DTO\Converter\MapConverter;
|
||||
@@ -141,6 +142,19 @@ class TypeNestedMap extends DTO
|
||||
}
|
||||
}
|
||||
|
||||
class TypeRawName extends DTO
|
||||
{
|
||||
public function __construct(
|
||||
#[RawName('arg_name')]
|
||||
public int $argName,
|
||||
#[RawName('vID')]
|
||||
public int $vID,
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class DTOTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testBasic()
|
||||
@@ -326,4 +340,15 @@ class DTOTest extends PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals($rawType, $testType);
|
||||
}
|
||||
|
||||
public function testRawName(){
|
||||
$rawType = [
|
||||
'arg_name' => 1,
|
||||
'vID' => 2,
|
||||
];
|
||||
$obj = TypeRawName::fromArray($rawType);
|
||||
$testType = $obj->toArray();
|
||||
|
||||
$this->assertEquals($rawType, $testType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user