Completed
Branch master (9e87a4)
by Jakub
04:40
created
src/Generator.php 2 patches
Unused Use Statements   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@
 block discarded – undo
5 5
 
6 6
 require_once(__DIR__ . "/functions.php");
7 7
 
8
-use cebe\markdown\GithubMarkdown,
9
-    Nette\Utils\Finder,
10
-    Nette\Neon\Neon,
11
-    Nette\Utils\FileSystem;
8
+use cebe\markdown\GithubMarkdown;
9
+use Nette\Utils\Finder;
10
+use Nette\Neon\Neon;
11
+use Nette\Utils\FileSystem;
12 12
 
13 13
 /**
14 14
  * Generator
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Nexendrie\SiteGenerator;
5 5
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
   protected $output;
27 27
   
28 28
   function __construct(string $source = NULL, string $output = NULL) {
29
-    if(is_null($source)) {
29
+    if (is_null($source)) {
30 30
       $source = findVendorDirectory() . "/../";
31 31
     }
32 32
     $this->setSource($source);
33
-    if(is_null($output)) {
33
+    if (is_null($output)) {
34 34
       $output = findVendorDirectory() . "/../public/";
35 35
     }
36 36
     FileSystem::createDir($output);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
    * @param string $source
49 49
    */
50 50
   function setSource(string $source) {
51
-    if(is_string($source) AND is_dir($source)) {
51
+    if (is_string($source) AND is_dir($source)) {
52 52
       $this->source = realpath($source);
53 53
     }
54 54
   }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
    * @param string $output
65 65
    */
66 66
   function setOutput(string $output) {
67
-    if(is_string($output)) {
67
+    if (is_string($output)) {
68 68
       $this->output = realpath($output);
69 69
     }
70 70
   }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     $meta = [
79 79
       "title" => ""
80 80
     ];
81
-    if(file_exists($metaFilename)) {
81
+    if (file_exists($metaFilename)) {
82 82
       $meta = Neon::decode(file_get_contents($metaFilename));
83 83
     }
84 84
     return $meta;
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
     $source = $parser->parse(file_get_contents($filename));
95 95
     $meta = $this->getMeta($filename);
96 96
     $html = file_get_contents(__DIR__ . "/template.html");
97
-    if(substr($source, -1) === PHP_EOL) {
97
+    if (substr($source, -1) === PHP_EOL) {
98 98
       $source = substr($source, 0, -1);
99 99
     }
100
-    if(strlen($meta["title"]) === 0) {
100
+    if (strlen($meta["title"]) === 0) {
101 101
       unset($meta["title"]);
102 102
       $html = str_replace("
103 103
   <title>%%title%%</title>", "", $html);
104 104
     }
105 105
     $meta["source"] = $source;
106
-    foreach($meta as $key => $value) {
106
+    foreach ($meta as $key => $value) {
107 107
       $html = str_replace("%%$key%%", $value, $html);
108 108
     }
109 109
     return $html;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
       ->from($this->source)
122 122
       ->exclude("vendor", ".git", "tests");
123 123
     /** @var \SplFileInfo $file */
124
-    foreach($files as $file) {
124
+    foreach ($files as $file) {
125 125
       $path = dirname($file->getRealPath());
126 126
       $path = str_replace($this->source, "", $path);
127 127
       $html = $this->createHtml($file->getRealPath());
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Nexendrie\SiteGenerator;
5 5
 
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function findVendorDirectory(): string {
10 10
   $recursionLimit = 10;
11
-  $findVendor = function ($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) {
12
-    if(!$recursionLimit--) {
11
+  $findVendor = function($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) {
12
+    if (!$recursionLimit--) {
13 13
       throw new \Exception("Cannot find vendor directory.");
14 14
     }
15 15
     $found = $dir . "/$dirName";
16
-    if(is_dir($found) || is_file($found)) {
16
+    if (is_dir($found) || is_file($found)) {
17 17
       return dirname($found);
18 18
     }
19 19
     return $findVendor($dirName, dirname($dir));
Please login to merge, or discard this patch.
src/generate-site.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Nexendrie\SiteGenerator;
5 5
 
Please login to merge, or discard this patch.