Passed
Push — parser-refactoring ( e758c6 )
by Luis
04:05
created
src/classes/processor/statistics.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
     public function __construct()
12 12
     {
13
-        $this->options   = new plProcessorOptions();
13
+        $this->options = new plProcessorOptions();
14 14
         $this->information = array();
15 15
     }
16 16
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         return 'text/plain';
27 27
     }
28 28
 
29
-    public function process( $input, $type )
29
+    public function process($input, $type)
30 30
     {
31 31
         // Initialize the values
32 32
         $this->information['interfaceCount']           = 0;
@@ -42,38 +42,38 @@  discard block
 block discarded – undo
42 42
         $this->information['privateTypedAttributes']   = 0;
43 43
 
44 44
         // Loop through the classes and interfaces
45
-        foreach ( $input->definitions() as $definition )
45
+        foreach ($input->definitions() as $definition)
46 46
         {
47
-            if ( $definition instanceof InterfaceDefinition )
47
+            if ($definition instanceof InterfaceDefinition)
48 48
             {
49 49
                 $this->information['interfaceCount']++;
50 50
             }
51 51
 
52
-            if ( $definition instanceof ClassDefinition )
52
+            if ($definition instanceof ClassDefinition)
53 53
             {
54 54
                 $this->information['classCount']++;
55 55
 
56
-                foreach( $definition->attributes as $attribute )
56
+                foreach ($definition->attributes as $attribute)
57 57
                 {
58
-                    switch ( $attribute->modifier )
58
+                    switch ($attribute->modifier)
59 59
                     {
60 60
                         case 'public':
61 61
                             $this->information['publicAttributeCount']++;
62
-                            if ( $attribute->type->isPresent() )
62
+                            if ($attribute->type->isPresent())
63 63
                             {
64 64
                                 $this->information['publicTypedAttributes']++;
65 65
                             }
66 66
                         break;
67 67
                         case 'protected':
68 68
                             $this->information['protectedAttributeCount']++;
69
-                            if ( $attribute->type->isPresent() )
69
+                            if ($attribute->type->isPresent())
70 70
                             {
71 71
                                 $this->information['protectedTypedAttributes']++;
72 72
                             }
73 73
                         break;
74 74
                         case 'private':
75 75
                             $this->information['privateAttributeCount']++;
76
-                            if ( $attribute->type->isPresent() )
76
+                            if ($attribute->type->isPresent())
77 77
                             {
78 78
                                 $this->information['privateTypedAttributes']++;
79 79
                             }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
                 }
83 83
             }
84 84
 
85
-            foreach( $definition->functions as $function )
85
+            foreach ($definition->functions as $function)
86 86
             {
87
-                switch ( $function->modifier )
87
+                switch ($function->modifier)
88 88
                 {
89 89
                     case 'public':
90 90
                         $this->information['publicFunctionCount']++;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
         $this->information['functionCount']       = $this->information['publicFunctionCount'] + $this->information['protectedFunctionCount'] + $this->information['privateFunctionCount'];
103 103
         $this->information['attributeCount']      = $this->information['publicAttributeCount'] + $this->information['protectedAttributeCount'] + $this->information['privateAttributeCount'];
104 104
         $this->information['typedAttributeCount'] = $this->information['publicTypedAttributes'] + $this->information['protectedTypedAttributes'] + $this->information['privateTypedAttributes'];
105
-        $this->information['attributesPerClass']  = round( $this->information['attributeCount'] / $this->information['classCount'], 2 );
106
-        $this->information['functionsPerClass']   = round( $this->information['functionCount'] / $this->information['classCount'], 2 );
105
+        $this->information['attributesPerClass']  = round($this->information['attributeCount'] / $this->information['classCount'], 2);
106
+        $this->information['functionsPerClass']   = round($this->information['functionCount'] / $this->information['classCount'], 2);
107 107
 
108 108
         // Generate the needed text output
109 109
         return <<<END
Please login to merge, or discard this patch.
src/classes/phuml.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,32 +18,32 @@  discard block
 block discarded – undo
18 18
         $this->files = [];
19 19
     }
20 20
 
21
-    public function addFile( $file ) 
21
+    public function addFile($file) 
22 22
     {
23 23
         $this->files[] = $file;
24 24
     }
25 25
 
26
-    public function addDirectory( $directory, $extension = 'php', $recursive = true ) 
26
+    public function addDirectory($directory, $extension = 'php', $recursive = true) 
27 27
     {
28
-        if ( $recursive === false ) 
28
+        if ($recursive === false) 
29 29
         {
30
-            $iterator = new DirectoryIterator( $directory );
30
+            $iterator = new DirectoryIterator($directory);
31 31
         }
32 32
         else
33 33
         {
34 34
             $iterator = new RecursiveIteratorIterator(
35
-                new RecursiveDirectoryIterator( $directory )
35
+                new RecursiveDirectoryIterator($directory)
36 36
             );
37 37
         }
38 38
 
39
-        foreach( $iterator as $entry ) 
39
+        foreach ($iterator as $entry) 
40 40
         {
41
-            if ( $entry->isDir() === true ) 
41
+            if ($entry->isDir() === true) 
42 42
             {
43 43
                 continue;
44 44
             }
45 45
             
46
-            if ( $sub = strtolower( substr( $entry->getFilename(), -1 * strlen( $extension ) ) ) !== strtolower( $extension ) ) 
46
+            if ($sub = strtolower(substr($entry->getFilename(), -1 * strlen($extension))) !== strtolower($extension)) 
47 47
             {
48 48
                 continue;
49 49
             }
@@ -52,77 +52,77 @@  discard block
 block discarded – undo
52 52
         }       
53 53
     }
54 54
 
55
-    public function addProcessor( $processor ) 
55
+    public function addProcessor($processor) 
56 56
     {
57
-        if ( count( $this->processors ) === 0 ) 
57
+        if (count($this->processors) === 0) 
58 58
         {
59 59
             // First processor must support application/phuml-structure
60
-            if ( !in_array( 'application/phuml-structure', $processor->getInputTypes() ) ) 
60
+            if (!in_array('application/phuml-structure', $processor->getInputTypes())) 
61 61
             {
62
-                throw new plPhumlInvalidProcessorChainException( 'application/phuml-structure', $processor->getInputTypes() );
62
+                throw new plPhumlInvalidProcessorChainException('application/phuml-structure', $processor->getInputTypes());
63 63
             }
64 64
         }
65 65
         else
66 66
         {
67
-            $this->checkProcessorCompatibility( end( $this->processors ), $processor );
67
+            $this->checkProcessorCompatibility(end($this->processors), $processor);
68 68
 
69 69
         }
70 70
         $this->processors[] = $processor;
71 71
     }
72 72
 
73
-    private function checkProcessorCompatibility( $first, $second ) 
73
+    private function checkProcessorCompatibility($first, $second) 
74 74
     {
75
-        if ( !( $first instanceof plProcessor ) || !( $second instanceof plProcessor ) ) 
75
+        if (!($first instanceof plProcessor) || !($second instanceof plProcessor)) 
76 76
         {
77 77
             throw new plPhumlInvalidProcessorException();
78 78
         }
79 79
 
80
-        if ( !in_array( $first->getOutputType(), $second->getInputTypes() ) ) 
80
+        if (!in_array($first->getOutputType(), $second->getInputTypes())) 
81 81
         {
82
-            throw new plPhumlInvalidProcessorChainException( $first->getOutputType(), $second->getInputTypes() );
82
+            throw new plPhumlInvalidProcessorChainException($first->getOutputType(), $second->getInputTypes());
83 83
         }
84 84
     }
85 85
 
86
-    public function generate( $outfile ) 
86
+    public function generate($outfile) 
87 87
     {
88 88
         echo "[|] Parsing class structure", "\n";
89
-        $structure = $this->generator->createStructure( $this->files );
89
+        $structure = $this->generator->createStructure($this->files);
90 90
         
91
-        $temporary = array( $structure, 'application/phuml-structure' );
92
-        foreach( $this->processors as $processor ) 
91
+        $temporary = array($structure, 'application/phuml-structure');
92
+        foreach ($this->processors as $processor) 
93 93
         {            
94 94
             preg_match( 
95 95
                 '@^pl([A-Z][a-z]*)Processor$@',
96
-                get_class( $processor ),
96
+                get_class($processor),
97 97
                 $matches
98 98
             );
99 99
 
100 100
             echo "[|] Running '" . $matches[1] . "' processor", "\n";
101 101
             $temporary = array( 
102
-                $processor->process( $temporary[0], $temporary[1] ),
102
+                $processor->process($temporary[0], $temporary[1]),
103 103
                 $processor->getOutputType(),
104 104
             );
105 105
         }
106 106
 
107 107
         echo "[|] Writing generated data to disk", "\n";
108
-        end( $this->processors )->writeToDisk( $temporary[0], $outfile );
108
+        end($this->processors)->writeToDisk($temporary[0], $outfile);
109 109
     }
110 110
 
111 111
 
112
-    public function __get( $key )
112
+    public function __get($key)
113 113
     {
114
-        if ( !array_key_exists( $key, $this->properties ) )
114
+        if (!array_key_exists($key, $this->properties))
115 115
         {
116
-            throw new plBasePropertyException( $key, plBasePropertyException::READ );
116
+            throw new plBasePropertyException($key, plBasePropertyException::READ);
117 117
         }
118 118
         return $this->properties[$key];
119 119
     }
120 120
 
121
-    public function __set( $key, $val )
121
+    public function __set($key, $val)
122 122
     {
123
-        if ( !array_key_exists( $key, $this->properties ) )
123
+        if (!array_key_exists($key, $this->properties))
124 124
         {
125
-            throw new plBasePropertyException( $key, plBasePropertyException::WRITE );
125
+            throw new plBasePropertyException($key, plBasePropertyException::WRITE);
126 126
         }
127 127
         $this->properties[$key] = $val;            
128 128
     }
Please login to merge, or discard this patch.