File tree 1 file changed +27
-1
lines changed 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 3
3
namespace Foxws \Algos \Algos ;
4
4
5
5
use Foxws \Algos \Enums \Status ;
6
+ use Illuminate \Contracts \Support \Arrayable ;
7
+ use Illuminate \Contracts \Support \Jsonable ;
8
+ use Illuminate \Support \Traits \Macroable ;
6
9
7
- class Result
10
+ class Result implements Arrayable, Jsonable
8
11
{
12
+ use Macroable;
13
+
9
14
public Algo $ algo ;
10
15
11
16
public ?Status $ status = null ;
@@ -56,4 +61,25 @@ public function with(string $key, mixed $value = null): static
56
61
57
62
return $ this ;
58
63
}
64
+
65
+ public function merge (array $ meta ): static
66
+ {
67
+ $ this ->meta = array_merge_recursive ($ this ->meta , $ meta );
68
+
69
+ return $ this ;
70
+ }
71
+
72
+ public function toJson ($ options = 0 ): string
73
+ {
74
+ return json_encode ($ this ->toArray (), $ options );
75
+ }
76
+
77
+ public function toArray (): array
78
+ {
79
+ return [
80
+ 'status ' => $ this ->status ,
81
+ 'message ' => $ this ->message ,
82
+ 'meta ' => $ this ->meta ,
83
+ ];
84
+ }
59
85
}
You can’t perform that action at this time.
0 commit comments