@@ -7,8 +7,8 @@ class SfeedFormat extends FormatAbstract
7
7
private function escape (string $ str )
8
8
{
9
9
$ str = str_replace ('\\' , '\\\\' , $ str );
10
- $ str = str_replace ("\n" , " \\n " , $ str );
11
- return str_replace ("\t" , " \\t " , $ str );
10
+ $ str = str_replace ("\n" , ' \\n ' , $ str );
11
+ return str_replace ("\t" , ' \\t ' , $ str );
12
12
}
13
13
14
14
private function getFirstEnclosure (array $ enclosures )
@@ -22,13 +22,12 @@ private function getFirstEnclosure(array $enclosures)
22
22
private function getCategories (array $ cats )
23
23
{
24
24
$ toReturn = '' ;
25
- $ i = 0 ;
25
+ $ i = 1 ;
26
26
foreach ($ cats as $ cat ) {
27
- $ toReturn .= $ cat ;
28
- if (count ($ cats ) < $ i ) {
27
+ $ toReturn .= trim ( $ cat) ;
28
+ if (count ($ cats ) > $ i++ ) {
29
29
$ toReturn .= '| ' ;
30
30
}
31
- $ i ++;
32
31
}
33
32
return $ toReturn ;
34
33
}
@@ -42,12 +41,18 @@ public function stringify()
42
41
$ toReturn .= sprintf (
43
42
"%s \t%s \t%s \t%s \thtml \t\t%s \t%s \t%s \n" ,
44
43
$ item ->toArray ()['timestamp ' ],
45
- $ this -> escape ( $ item ->toArray ()['title ' ]),
44
+ preg_replace ( ' /\s/ ' , ' ' , $ item ->toArray ()['title ' ]),
46
45
$ item ->toArray ()['uri ' ],
47
46
$ this ->escape ($ item ->toArray ()['content ' ]),
48
47
$ item ->toArray ()['author ' ],
49
- $ this ->getFirstEnclosure ($ item ->toArray ()['enclosures ' ]),
50
- $ this ->getCategories ($ item ->toArray ()['categories ' ])
48
+ $ this ->getFirstEnclosure (
49
+ $ item ->toArray ()['enclosures ' ]
50
+ ),
51
+ $ this ->escape (
52
+ $ this ->getCategories (
53
+ $ item ->toArray ()['categories ' ]
54
+ )
55
+ )
51
56
);
52
57
}
53
58
0 commit comments