@@ -8,9 +8,9 @@ class RssConfig
88 * The configured feeds.
99 * Array keys are the feed URLs and values are arrays of tags as strings.
1010 * Tag strings include their '#' prefix.
11- * @var array<string, array{name: string, tags: string[], color: string}>
11+ * @var array<string, array{name: string, tags: string[], color: string, hidden: bool }>
1212 */
13- protected $ feeds = [];
13+ protected array $ feeds = [];
1414
1515 /**
1616 * Get all feed URLs
@@ -24,12 +24,13 @@ public function getFeedUrls(): array
2424 /**
2525 * Add a new feed to the config.
2626 */
27- public function addFeed (string $ feed , string $ name , array $ tags = [], string $ color = '' ): void
27+ public function addFeed (string $ feed , string $ name , array $ tags = [], string $ color = '' , bool $ hidden = false ): void
2828 {
2929 $ this ->feeds [$ feed ] = [
3030 'name ' => $ name ,
3131 'tags ' => $ tags ,
3232 'color ' => $ color ,
33+ 'hidden ' => $ hidden ,
3334 ];
3435 }
3536
@@ -73,6 +74,14 @@ public function getColor(string $feed): string
7374 return $ this ->feeds [$ feed ]['color ' ] ?? '' ;
7475 }
7576
77+ /**
78+ * Get the hidden status for the given feed.
79+ */
80+ public function getHidden (string $ feed ): bool
81+ {
82+ return $ this ->feeds [$ feed ]['hidden ' ] ?? false ;
83+ }
84+
7685 /**
7786 * Get the configuration as a string.
7887 */
@@ -92,6 +101,10 @@ public function toString(): string
92101 $ line .= " {$ tag }" ;
93102 }
94103
104+ if ($ details ['hidden ' ]) {
105+ $ line = '- ' . $ line ;
106+ }
107+
95108 $ lines [] = $ line ;
96109 }
97110
@@ -107,8 +120,14 @@ public function parseFromString(string $configString): void
107120
108121 foreach ($ lines as $ line ) {
109122 $ line = trim ($ line );
110- $ parts = explode ( ' ' , $ line ) ;
123+ $ hidden = false ;
111124
125+ if (str_starts_with ($ line , '- ' )) {
126+ $ hidden = true ;
127+ $ line = ltrim ($ line , '- ' );
128+ }
129+
130+ $ parts = explode (' ' , $ line );
112131 if (empty ($ line ) || str_starts_with ($ line , '# ' ) || count ($ parts ) < 2 ) {
113132 continue ;
114133 }
@@ -127,7 +146,7 @@ public function parseFromString(string $configString): void
127146 $ tags = array_filter (array_slice ($ parts , 2 ), fn ($ str ) => str_starts_with ($ str , '# ' ));
128147
129148 if (str_starts_with ($ url , 'http:// ' ) || str_starts_with ($ url , 'https:// ' )) {
130- $ this ->addFeed ($ url , $ name , $ tags , $ color );
149+ $ this ->addFeed ($ url , $ name , $ tags , $ color, $ hidden );
131150 }
132151 }
133152 }
0 commit comments