File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change 7
7
use WordPress \AiClient \Common \AbstractDataValueObject ;
8
8
use WordPress \AiClient \Files \DTO \File ;
9
9
use WordPress \AiClient \Messages \DTO \Message ;
10
- use WordPress \AiClient \Messages \Enums \MessagePartTypeEnum ;
11
10
use WordPress \AiClient \Results \Contracts \ResultInterface ;
12
11
13
12
/**
@@ -403,9 +402,7 @@ public function toArray(): array
403
402
{
404
403
return [
405
404
'id ' => $ this ->id ,
406
- 'candidates ' => array_map (function (Candidate $ candidate ) {
407
- return $ candidate ->toArray ();
408
- }, $ this ->candidates ),
405
+ 'candidates ' => array_map (fn (Candidate $ candidate ) => $ candidate ->toArray (), $ this ->candidates ),
409
406
'tokenUsage ' => $ this ->tokenUsage ->toArray (),
410
407
'providerMetadata ' => $ this ->providerMetadata ,
411
408
];
@@ -419,9 +416,7 @@ public function toArray(): array
419
416
public static function fromArray (array $ array ): GenerativeAiResult
420
417
{
421
418
$ candidatesData = $ array ['candidates ' ];
422
- $ candidates = array_map (function (array $ candidateData ) {
423
- return Candidate::fromArray ($ candidateData );
424
- }, $ candidatesData );
419
+ $ candidates = array_map (fn (array $ candidateData ) => Candidate::fromArray ($ candidateData ), $ candidatesData );
425
420
426
421
$ tokenUsageData = $ array ['tokenUsage ' ];
427
422
$ providerMetadata = $ array ['providerMetadata ' ] ?? [];
You can’t perform that action at this time.
0 commit comments