@@ -26,23 +26,39 @@ class Job
2626 private array $ variables ;
2727 private string $ user ;
2828
29+ private function __construct (string $ id , string $ pipeline , TaskResults $ taskResults , bool $ completed , bool $ canceled , bool $ errored , \DateTimeImmutable $ created , ?\DateTimeImmutable $ start , ?\DateTimeImmutable $ end , ?string $ lastError , array $ variables , string $ user )
30+ {
31+ $ this ->id = $ id ;
32+ $ this ->pipeline = $ pipeline ;
33+ $ this ->taskResults = $ taskResults ;
34+ $ this ->completed = $ completed ;
35+ $ this ->canceled = $ canceled ;
36+ $ this ->errored = $ errored ;
37+ $ this ->created = $ created ;
38+ $ this ->start = $ start ;
39+ $ this ->end = $ end ;
40+ $ this ->lastError = $ lastError ;
41+ $ this ->variables = $ variables ;
42+ $ this ->user = $ user ;
43+ }
44+
45+
2946 public static function fromJsonArray (array $ in ): self
3047 {
31- $ job = new static ();
32- $ job ->id = $ in ['id ' ];
33- $ job ->pipeline = $ in ['pipeline ' ];
34- $ job ->taskResults = TaskResults::fromJsonArray ($ in ['tasks ' ]);;
35- $ job ->completed = $ in ['completed ' ];
36- $ job ->canceled = $ in ['canceled ' ];
37- $ job ->errored = $ in ['errored ' ];
38- $ job ->created = \DateTimeImmutable::createFromFormat (\DateTimeInterface::W3C , $ in ['created ' ]);
39- $ job ->start = isset ($ in ['start ' ]) ? \DateTimeImmutable::createFromFormat (\DateTimeInterface::W3C , $ in ['start ' ]) : null ;
40- $ job ->end = isset ($ in ['end ' ]) ? \DateTimeImmutable::createFromFormat (\DateTimeInterface::W3C , $ in ['end ' ]) : null ;
41- $ job ->lastError = $ in ['lastError ' ];
42- $ job ->variables = $ in ['variables ' ] ?? [];
43- $ job ->user = $ in ['user ' ];
44-
45- return $ job ;
48+ return new self (
49+ $ in ['id ' ],
50+ $ in ['pipeline ' ],
51+ TaskResults::fromJsonArray ($ in ['tasks ' ]),
52+ $ in ['completed ' ],
53+ $ in ['canceled ' ],
54+ $ in ['errored ' ],
55+ \DateTimeImmutable::createFromFormat (\DateTimeInterface::W3C , $ in ['created ' ]),
56+ isset ($ in ['start ' ]) ? \DateTimeImmutable::createFromFormat (\DateTimeInterface::W3C , $ in ['start ' ]) : null ,
57+ isset ($ in ['end ' ]) ? \DateTimeImmutable::createFromFormat (\DateTimeInterface::W3C , $ in ['end ' ]) : null ,
58+ $ in ['lastError ' ] ?? '' ,
59+ $ in ['variables ' ] ?? [],
60+ $ in ['user ' ]
61+ );
4662 }
4763
4864 /**
0 commit comments