@@ -25,10 +25,10 @@ public function __construct(array $config = [])
2525 }
2626
2727 /**
28- * @param string[]|null $attributes = []
28+ * @param string[]|Attribute[]| null $attributes = []
2929 * @return string[]|null|self
3030 */
31- public static function attributes (array |null $ attributes = [] ): array |null |self
31+ public static function attributes (array |null $ attributes = null ): array |null |self
3232 {
3333 if (is_null ($ attributes )) {
3434 return self ::$ config ['attributes ' ] ?? null ;
@@ -41,10 +41,11 @@ public static function attributes(array|null $attributes = []): array|null|self
4141
4242 /**
4343 * @param string|Foreground|int|int[]|null $foreground = null
44- * @return string|int|int[]|null|self
44+ * @return string|Foreground| int|int[]|null|self
4545 */
46- public static function foreground (string |Foreground |int |array |null $ foreground = null ): string |int |array |null |self
47- {
46+ public static function foreground (
47+ string |Foreground |int |array |null $ foreground = null
48+ ): string |Foreground |int |array |null |self {
4849 if (is_null ($ foreground )) {
4950 return self ::$ config ['foreground ' ] ?? null ;
5051 }
@@ -54,10 +55,11 @@ public static function foreground(string|Foreground|int|array|null $foreground =
5455
5556 /**
5657 * @param string|Background|int|int[]|null $background = null
57- * @return string|int|int[]|null|self
58+ * @return string|Background| int|int[]|null|self
5859 */
59- public static function background (string |Background |int |array |null $ background = null ): string |int |array |null |self
60- {
60+ public static function background (
61+ string |Background |int |array |null $ background = null
62+ ): string |Background |int |array |null |self {
6163 if (is_null ($ background )) {
6264 return self ::$ config ['background ' ] ?? null ;
6365 }
@@ -194,10 +196,11 @@ public static function codes(array $config = []): string
194196
195197 public static function encode (string $ string , string $ eol = '' ): string
196198 {
197- return sprintf (
199+ $ codes = static ::codes (static ::$ config );
200+ return empty ($ codes ) ? $ string : sprintf (
198201 '%s[%sm%s%s[m%s ' ,
199202 static ::ESC ,
200- static :: codes ( static :: $ config ) ,
203+ $ codes ,
201204 $ string ,
202205 static ::ESC ,
203206 $ eol ,
0 commit comments