Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
DatabaseRowResult | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
mapping | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\Core\Database; |
6 | |
7 | use PeServer\Core\Database\DatabaseResultBase; |
8 | use PeServer\Core\Serialization\IMapper; |
9 | use PeServer\Core\Serialization\Mapper; |
10 | |
11 | /** |
12 | * 単一問い合わせ結果。 |
13 | * |
14 | * @template TFieldArray of FieldArrayAlias |
15 | * @immutable |
16 | */ |
17 | class DatabaseRowResult extends DatabaseResultBase |
18 | { |
19 | /** |
20 | * 生成。 |
21 | * |
22 | * @param array<string|int,mixed> $fields フィールド一覧。 |
23 | * @phpstan-param TFieldArray $fields |
24 | */ |
25 | public function __construct( |
26 | array $columns, |
27 | int $resultCount, |
28 | public readonly array $fields |
29 | ) { |
30 | parent::__construct($columns, $resultCount); |
31 | } |
32 | |
33 | #region function |
34 | |
35 | /** |
36 | * 結果をマッピング。 |
37 | * |
38 | * @template TObject of object |
39 | * @param string|object $classNameOrObject |
40 | * @phpstan-param class-string<TObject>|TObject $classNameOrObject |
41 | * @param IMapper|null $mapper |
42 | * @return object |
43 | * @phpstan-return TObject |
44 | */ |
45 | public function mapping(string|object $classNameOrObject, IMapper $mapper = null): object |
46 | { |
47 | return $this->mappingImpl($this->fields, $classNameOrObject, $mapper ?? new Mapper()); |
48 | } |
49 | |
50 | #endregion |
51 | } |