@@ -877,11 +877,9 @@ public function updateCommitStatus(string $repositoryName, string $commitHash, s
877877 * status can be one of: queued, in_progress, completed
878878 * conclusion (required when status=completed) can be one of: action_required, cancelled, failure, neutral, success, skipped, timed_out
879879 *
880- * @return array<mixed>
881- */
882- /**
883880 * @param array<mixed> $annotations
884881 * @param array<mixed> $images
882+ * @return array<mixed>
885883 */
886884 public function createCheckRun (
887885 string $ owner ,
@@ -917,20 +915,8 @@ public function createCheckRun(
917915 ], fn ($ value ) => !empty ($ value ))
918916 );
919917
920- if (!empty ($ title ) || !empty ($ summary )) {
921- $ output = array_filter ([
922- 'title ' => $ title ,
923- 'summary ' => $ summary ,
924- 'text ' => $ text ,
925- ], fn ($ value ) => !empty ($ value ));
926-
927- if (!empty ($ annotations )) {
928- $ output ['annotations ' ] = $ annotations ;
929- }
930- if (!empty ($ images )) {
931- $ output ['images ' ] = $ images ;
932- }
933-
918+ $ output = $ this ->buildCheckRunOutput ($ title , $ summary , $ text , $ annotations , $ images );
919+ if (!empty ($ output )) {
934920 $ body ['output ' ] = $ output ;
935921 }
936922
@@ -991,20 +977,8 @@ public function updateCheckRun(
991977 'completed_at ' => $ completedAt ,
992978 ], fn ($ value ) => !empty ($ value ));
993979
994- if (!empty ($ title ) || !empty ($ summary )) {
995- $ output = array_filter ([
996- 'title ' => $ title ,
997- 'summary ' => $ summary ,
998- 'text ' => $ text ,
999- ], fn ($ value ) => !empty ($ value ));
1000-
1001- if (!empty ($ annotations )) {
1002- $ output ['annotations ' ] = $ annotations ;
1003- }
1004- if (!empty ($ images )) {
1005- $ output ['images ' ] = $ images ;
1006- }
1007-
980+ $ output = $ this ->buildCheckRunOutput ($ title , $ summary , $ text , $ annotations , $ images );
981+ if (!empty ($ output )) {
1008982 $ body ['output ' ] = $ output ;
1009983 }
1010984
@@ -1013,6 +987,35 @@ public function updateCheckRun(
1013987 return $ response ['body ' ] ?? [];
1014988 }
1015989
990+ /**
991+ * Builds the output block for a check run.
992+ *
993+ * @param array<mixed> $annotations
994+ * @param array<mixed> $images
995+ * @return array<mixed>
996+ */
997+ private function buildCheckRunOutput (string $ title , string $ summary , string $ text , array $ annotations , array $ images ): array
998+ {
999+ if (empty ($ title ) && empty ($ summary )) {
1000+ return [];
1001+ }
1002+
1003+ $ output = array_filter ([
1004+ 'title ' => $ title ,
1005+ 'summary ' => $ summary ,
1006+ 'text ' => $ text ,
1007+ ], fn ($ value ) => !empty ($ value ));
1008+
1009+ if (!empty ($ annotations )) {
1010+ $ output ['annotations ' ] = $ annotations ;
1011+ }
1012+ if (!empty ($ images )) {
1013+ $ output ['images ' ] = $ images ;
1014+ }
1015+
1016+ return $ output ;
1017+ }
1018+
10161019 /**
10171020 * Generates a clone command using app access token
10181021 */
0 commit comments