Passed
Branch master (064662)
by Patryk
04:33 queued 02:25
created
src/Graph/Generate.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
     namespace PatchFind\Graph;
4 4
     
5
-    class Generate implements GenerateInterface{
5
+    class Generate implements GenerateInterface {
6 6
         
7 7
         /**
8 8
          * width of graph
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
          * @param  int    $height
24 24
          * @return array
25 25
          */
26
-        public function createGraph($width, $height){
26
+        public function createGraph($width, $height) {
27 27
             $this->x_w = $width;
28 28
             $this->y_h = $height;
29 29
             
@@ -31,25 +31,25 @@  discard block
 block discarded – undo
31 31
             $modY = ceil($height/2);
32 32
 
33 33
             $relations = array();
34
-            for($y = 0; $y <= $height; $y++){
35
-                for($x = 0; $x <= $width; $x++){
34
+            for ($y = 0; $y <= $height; $y++) {
35
+                for ($x = 0; $x <= $width; $x++) {
36 36
                     $k = $x; $k2 = $y;
37
-                    if($x<$modX) $k = $width-$x;
38
-                    if($y<$modY) $k2 = $height-$y;
37
+                    if ($x < $modX) $k = $width-$x;
38
+                    if ($y < $modY) $k2 = $height-$y;
39 39
                     $k3 = $k;
40
-                    if($k2>$k) $k3 = $k2;
40
+                    if ($k2 > $k) $k3 = $k2;
41 41
                   
42 42
                     $tmpX = $x-1; $tmpY = $y;
43
-                    if($this->checkParams($tmpX, $tmpY)) $relations["($tmpX,$tmpY)"]["($x,$y)"] = $k3;
43
+                    if ($this->checkParams($tmpX, $tmpY)) $relations["($tmpX,$tmpY)"]["($x,$y)"] = $k3;
44 44
                    
45 45
                     $tmpX2 = $x+1; $tmpY2 = $y;
46
-                    if($this->checkParams($tmpX2, $tmpY2)) $relations["($tmpX2,$tmpY2)"]["($x,$y)"] = $k3;
46
+                    if ($this->checkParams($tmpX2, $tmpY2)) $relations["($tmpX2,$tmpY2)"]["($x,$y)"] = $k3;
47 47
 
48 48
                     $tmpX3 = $x; $tmpY3 = $y-1;
49
-                    if($this->checkParams($tmpX3, $tmpY3)) $relations["($tmpX3,$tmpY3)"]["($x,$y)"] = $k3;
49
+                    if ($this->checkParams($tmpX3, $tmpY3)) $relations["($tmpX3,$tmpY3)"]["($x,$y)"] = $k3;
50 50
                     
51 51
                     $tmpX4 = $x; $tmpY4 = $y+1;
52
-                    if($this->checkParams($tmpX4, $tmpY4)) $relations["($tmpX4,$tmpY4)"]["($x,$y)"] = $k3;
52
+                    if ($this->checkParams($tmpX4, $tmpY4)) $relations["($tmpX4,$tmpY4)"]["($x,$y)"] = $k3;
53 53
                 }
54 54
             }
55 55
             
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
          * @param  string $file
63 63
          * @return array
64 64
          */
65
-        public function loadFromFile($file){
65
+        public function loadFromFile($file) {
66 66
             
67 67
             $res = @imagecreatefromjpeg($file);
68 68
            
69
-            if(!$res){
69
+            if (!$res) {
70 70
                 $width = imagesx($res);
71 71
                 $height = imagesy($res);
72 72
 
73 73
                 $new_tab = array();
74
-                for($y = 0; $y <= $height; $y++){
75
-                    for($x = 0; $x <= $width; $x++){
76
-                        if($y==$height || $x==$width){
74
+                for ($y = 0; $y <= $height; $y++) {
75
+                    for ($x = 0; $x <= $width; $x++) {
76
+                        if ($y==$height || $x==$width) {
77 77
                             $color = 10;
78
-                        }else{
78
+                        }else {
79 79
                             $color = imagecolorat($res, $x, $y);
80
-                            if(!$color) $color = 255;
80
+                            if (!$color) $color = 255;
81 81
                         }
82 82
                         $new_tab[$x][$y] = $color;
83 83
                     }
@@ -90,29 +90,29 @@  discard block
 block discarded – undo
90 90
                 $modY = ceil($height/2);
91 91
 
92 92
                 $relations = array();
93
-                for($y = 0; $y <= $height; $y++){
94
-                    for($x = 0; $x <= $width; $x++){
93
+                for ($y = 0; $y <= $height; $y++) {
94
+                    for ($x = 0; $x <= $width; $x++) {
95 95
 
96
-                        if($new_tab[$x][$y]<=100){
96
+                        if ($new_tab[$x][$y] <= 100) {
97 97
                            $k3 = 9999; 
98
-                        }else{
98
+                        }else {
99 99
                             $k = $x; $k2 = $y;
100
-                            if($x<$modX) $k = $width-$x;
101
-                            if($y<$modY) $k2 = $height-$y;
100
+                            if ($x < $modX) $k = $width-$x;
101
+                            if ($y < $modY) $k2 = $height-$y;
102 102
                             $k3 = $k;
103
-                            if($k2>$k) $k3 = $k2;
103
+                            if ($k2 > $k) $k3 = $k2;
104 104
                         }
105 105
                         $tmpX = $x-1; $tmpY = $y;
106
-                        if($this->checkParams($tmpX, $tmpY)) $relations["($tmpX,$tmpY)"]["($x,$y)"] = $k3;
106
+                        if ($this->checkParams($tmpX, $tmpY)) $relations["($tmpX,$tmpY)"]["($x,$y)"] = $k3;
107 107
 
108 108
                         $tmpX2 = $x+1; $tmpY2 = $y;
109
-                        if($this->checkParams($tmpX2, $tmpY2)) $relations["($tmpX2,$tmpY2)"]["($x,$y)"] = $k3;
109
+                        if ($this->checkParams($tmpX2, $tmpY2)) $relations["($tmpX2,$tmpY2)"]["($x,$y)"] = $k3;
110 110
 
111 111
                         $tmpX3 = $x; $tmpY3 = $y-1;
112
-                        if($this->checkParams($tmpX3, $tmpY3)) $relations["($tmpX3,$tmpY3)"]["($x,$y)"] = $k3;
112
+                        if ($this->checkParams($tmpX3, $tmpY3)) $relations["($tmpX3,$tmpY3)"]["($x,$y)"] = $k3;
113 113
 
114 114
                         $tmpX4 = $x; $tmpY4 = $y+1;
115
-                        if($this->checkParams($tmpX4, $tmpY4)) $relations["($tmpX4,$tmpY4)"]["($x,$y)"] = $k3;
115
+                        if ($this->checkParams($tmpX4, $tmpY4)) $relations["($tmpX4,$tmpY4)"]["($x,$y)"] = $k3;
116 116
                     }
117 117
                 }
118 118
                 $relations = $res;
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
          * @param  int $tmpY
131 131
          * @return bool
132 132
          */
133
-        private function checkParams($tmpX, $tmpY){
134
-            if($tmpX >= 0 && $tmpY >= 0 && $tmpX <= $this->x_w && $tmpY <= $this->y_h){
133
+        private function checkParams($tmpX, $tmpY) {
134
+            if ($tmpX >= 0 && $tmpY >= 0 && $tmpX <= $this->x_w && $tmpY <= $this->y_h) {
135 135
                 $output = true;
136
-            }else{
136
+            }else {
137 137
                 $output = false;
138 138
             }
139 139
             
Please login to merge, or discard this patch.