@@ -13,7 +13,7 @@ |
||
13 | 13 | * Parses a specific XML file |
14 | 14 | * |
15 | 15 | * @param string $inputFile File to parse |
16 | - * @return \Generator |
|
16 | + * @return \Iterator |
|
17 | 17 | */ |
18 | 18 | public function parse($inputFile) |
19 | 19 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | while ($reader->read() && $reader->name !== 'item'); |
27 | 27 | |
28 | - while($reader->name == 'item') { |
|
28 | + while ($reader->name == 'item') { |
|
29 | 29 | $xml = simplexml_import_dom($dom->importNode($reader->expand(), true)); |
30 | 30 | $wpItems = $xml->children($WPNamespace); |
31 | 31 | $content = $xml->children($DCNamespace)->encoded; |
@@ -33,17 +33,17 @@ discard block |
||
33 | 33 | $categories = []; |
34 | 34 | $tags = []; |
35 | 35 | |
36 | - foreach($xml->category as $category) { |
|
37 | - if('category' == $category->attributes()->domain) { |
|
36 | + foreach ($xml->category as $category) { |
|
37 | + if ('category' == $category->attributes()->domain) { |
|
38 | 38 | $categories[] = (string)$category; |
39 | 39 | } |
40 | 40 | |
41 | - if('post_tag' == $category->attributes()->domain) { |
|
41 | + if ('post_tag' == $category->attributes()->domain) { |
|
42 | 42 | $tags[] = (string)$category; |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - if($wpItems) { |
|
46 | + if ($wpItems) { |
|
47 | 47 | $post_type = (string)$wpItems->post_type; |
48 | 48 | $data = [ |
49 | 49 | 'type' => $post_type, |
@@ -52,10 +52,10 @@ |
||
52 | 52 | */ |
53 | 53 | public function parse() |
54 | 54 | { |
55 | - foreach($this->parser->parse($this->inputFile) as $item) { |
|
55 | + foreach ($this->parser->parse($this->inputFile) as $item) { |
|
56 | 56 | $writer = WriterFactory::create($item['type'], $this->config); |
57 | 57 | |
58 | - if($writer) { |
|
58 | + if ($writer) { |
|
59 | 59 | $writer->write($item); |
60 | 60 | } |
61 | 61 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public static function create($class) |
21 | 21 | { |
22 | 22 | $className = 'Fillet\\Parser\\' . ucfirst($class); |
23 | - if(class_exists($className)) { |
|
23 | + if (class_exists($className)) { |
|
24 | 24 | /** @var ParserInterface $parser */ |
25 | 25 | $parser = new $className(); |
26 | 26 | return $parser; |
@@ -22,14 +22,14 @@ |
||
22 | 22 | $filename = $this->generateSlug($data['title']); |
23 | 23 | |
24 | 24 | $headerData = [ |
25 | - 'title' => $data['title'], |
|
26 | - 'date' => $post_date_string, |
|
27 | - 'layout' => 'page', |
|
28 | - 'slug' => $filename, |
|
29 | - ]; |
|
25 | + 'title' => $data['title'], |
|
26 | + 'date' => $post_date_string, |
|
27 | + 'layout' => 'page', |
|
28 | + 'slug' => $filename, |
|
29 | + ]; |
|
30 | 30 | |
31 | - $dumper = new YamlDumper(); |
|
32 | - $header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL; |
|
31 | + $dumper = new YamlDumper(); |
|
32 | + $header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL; |
|
33 | 33 | |
34 | 34 | $filename = $this->destinationFolder . '/' . $filename; |
35 | 35 | if ($this->isMarkdownEnabled()) { |
@@ -11,28 +11,28 @@ |
||
11 | 11 | */ |
12 | 12 | class PostWriter extends AbstractWriter |
13 | 13 | { |
14 | - /** |
|
15 | - * Write out a set of data into a file |
|
16 | - * |
|
17 | - * @param array $data Data to use for constructing the page |
|
18 | - */ |
|
14 | + /** |
|
15 | + * Write out a set of data into a file |
|
16 | + * |
|
17 | + * @param array $data Data to use for constructing the page |
|
18 | + */ |
|
19 | 19 | public function write($data) |
20 | 20 | { |
21 | 21 | $post_date_string = $data['post_date']->format('Y-m-d H:i:s'); |
22 | 22 | $slug = $this->generateSlug($data['title']); |
23 | 23 | $filename = $data['post_date']->format('Y-m-d') . '-' . $slug; |
24 | 24 | |
25 | - $headerData = [ |
|
26 | - 'title' => $data['title'], |
|
27 | - 'date' => $post_date_string, |
|
28 | - 'layout' => 'post', |
|
29 | - 'slug' => $slug, |
|
30 | - 'categories' => $data['categories'], |
|
31 | - 'tags' => $data['tags'], |
|
32 | - ]; |
|
25 | + $headerData = [ |
|
26 | + 'title' => $data['title'], |
|
27 | + 'date' => $post_date_string, |
|
28 | + 'layout' => 'post', |
|
29 | + 'slug' => $slug, |
|
30 | + 'categories' => $data['categories'], |
|
31 | + 'tags' => $data['tags'], |
|
32 | + ]; |
|
33 | 33 | |
34 | - $dumper = new YamlDumper(); |
|
35 | - $header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL; |
|
34 | + $dumper = new YamlDumper(); |
|
35 | + $header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL; |
|
36 | 36 | |
37 | 37 | $filename = $this->destinationFolder . $filename; |
38 | 38 | if ($this->isMarkdownEnabled()) { |
@@ -22,13 +22,13 @@ |
||
22 | 22 | public static function create($postType, $config, $throwExceptionOnInvalidWriter = false) |
23 | 23 | { |
24 | 24 | $className = 'Fillet\\Writer\\' . ucfirst($postType) . 'Writer'; |
25 | - if(class_exists($className)) { |
|
25 | + if (class_exists($className)) { |
|
26 | 26 | /** @var WriterInterface $writer */ |
27 | 27 | $writer = new $className($config['destinationFolders'][$postType], $config); |
28 | 28 | return $writer; |
29 | 29 | } |
30 | 30 | |
31 | - if($throwExceptionOnInvalidWriter) { |
|
31 | + if ($throwExceptionOnInvalidWriter) { |
|
32 | 32 | throw new \Exception('There is no writer for ' . $postType); |
33 | 33 | } |
34 | 34 | } |