@@ -3,24 +3,24 @@ |
||
3 | 3 | abstract class plExternalCommandProcessor extends plProcessor |
4 | 4 | { |
5 | 5 | |
6 | - abstract public function execute( $infile, $outfile, $type ); |
|
6 | + abstract public function execute($infile, $outfile, $type); |
|
7 | 7 | |
8 | - public function process( $input, $type ) |
|
8 | + public function process($input, $type) |
|
9 | 9 | { |
10 | 10 | // Create temporary datafiles |
11 | - $infile = tempnam( '/tmp', 'phuml' ); |
|
12 | - $outfile = tempnam( '/tmp', 'phuml' ); |
|
11 | + $infile = tempnam('/tmp', 'phuml'); |
|
12 | + $outfile = tempnam('/tmp', 'phuml'); |
|
13 | 13 | |
14 | - file_put_contents( $infile, $input ); |
|
14 | + file_put_contents($infile, $input); |
|
15 | 15 | |
16 | - unlink( $outfile ); |
|
16 | + unlink($outfile); |
|
17 | 17 | |
18 | - $this->execute( $infile, $outfile, $type ); |
|
18 | + $this->execute($infile, $outfile, $type); |
|
19 | 19 | |
20 | - $outdata = file_get_contents( $outfile ); |
|
20 | + $outdata = file_get_contents($outfile); |
|
21 | 21 | |
22 | - unlink( $infile ); |
|
23 | - unlink( $outfile ); |
|
22 | + unlink($infile); |
|
23 | + unlink($outfile); |
|
24 | 24 | |
25 | 25 | return $outdata; |
26 | 26 | } |
@@ -26,8 +26,7 @@ discard block |
||
26 | 26 | if ( $recursive === false ) |
27 | 27 | { |
28 | 28 | $iterator = new DirectoryIterator( $directory ); |
29 | - } |
|
30 | - else |
|
29 | + } else |
|
31 | 30 | { |
32 | 31 | $iterator = new RecursiveIteratorIterator( |
33 | 32 | new RecursiveDirectoryIterator( $directory ) |
@@ -59,8 +58,7 @@ discard block |
||
59 | 58 | { |
60 | 59 | throw new plPhumlInvalidProcessorChainException( 'application/phuml-structure', $processor->getInputTypes() ); |
61 | 60 | } |
62 | - } |
|
63 | - else |
|
61 | + } else |
|
64 | 62 | { |
65 | 63 | $this->checkProcessorCompatibility( end( $this->processors ), $processor ); |
66 | 64 |
@@ -18,32 +18,32 @@ discard block |
||
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 |
||
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 | } |
@@ -21,17 +21,17 @@ |
||
21 | 21 | return 'image/png'; |
22 | 22 | } |
23 | 23 | |
24 | - public function execute( $infile, $outfile, $type ) |
|
24 | + public function execute($infile, $outfile, $type) |
|
25 | 25 | { |
26 | 26 | exec( |
27 | - 'dot -Tpng -o ' . escapeshellarg( $outfile ) . ' ' . escapeshellarg( $infile ), |
|
27 | + 'dot -Tpng -o ' . escapeshellarg($outfile) . ' ' . escapeshellarg($infile), |
|
28 | 28 | $output, |
29 | 29 | $return |
30 | 30 | ); |
31 | 31 | |
32 | - if ( $return !== 0 ) |
|
32 | + if ($return !== 0) |
|
33 | 33 | { |
34 | - throw new plProcessorExternalExecutionException( $output ); |
|
34 | + throw new plProcessorExternalExecutionException($output); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -8,20 +8,20 @@ discard block |
||
8 | 8 | |
9 | 9 | protected $properties = array(); |
10 | 10 | |
11 | - public function __get( $key ) |
|
11 | + public function __get($key) |
|
12 | 12 | { |
13 | - if ( !array_key_exists( $key, $this->properties ) ) |
|
13 | + if (!array_key_exists($key, $this->properties)) |
|
14 | 14 | { |
15 | - throw new plProcessorOptionException( $key, plProcessorOptionException::READ ); |
|
15 | + throw new plProcessorOptionException($key, plProcessorOptionException::READ); |
|
16 | 16 | } |
17 | 17 | return $this->properties[$key]['data']; |
18 | 18 | } |
19 | 19 | |
20 | - public function __set( $key, $val ) |
|
20 | + public function __set($key, $val) |
|
21 | 21 | { |
22 | - if ( !array_key_exists( $key, $this->properties ) ) |
|
22 | + if (!array_key_exists($key, $this->properties)) |
|
23 | 23 | { |
24 | - throw new plProcessorOptionException( $key, plProcessorOptionException::WRITE ); |
|
24 | + throw new plProcessorOptionException($key, plProcessorOptionException::WRITE); |
|
25 | 25 | } |
26 | 26 | $this->properties[$key]['data'] = $val; |
27 | 27 | } |
@@ -29,27 +29,27 @@ discard block |
||
29 | 29 | public function getOptions() |
30 | 30 | { |
31 | 31 | $options = array(); |
32 | - foreach( $this->properties as $key => $property ) |
|
32 | + foreach ($this->properties as $key => $property) |
|
33 | 33 | { |
34 | 34 | $options[] = $key; |
35 | 35 | } |
36 | 36 | return $options; |
37 | 37 | } |
38 | 38 | |
39 | - public function getOptionDescription( $option ) |
|
39 | + public function getOptionDescription($option) |
|
40 | 40 | { |
41 | - if ( !array_key_exists( $option, $this->properties ) ) |
|
41 | + if (!array_key_exists($option, $this->properties)) |
|
42 | 42 | { |
43 | - throw new plProcessorOptionException( $option, plProcessorOptionException::UNKNOWN ); |
|
43 | + throw new plProcessorOptionException($option, plProcessorOptionException::UNKNOWN); |
|
44 | 44 | } |
45 | 45 | return $this->properties[$option]['description']; |
46 | 46 | } |
47 | 47 | |
48 | - public function getOptionType( $option ) |
|
48 | + public function getOptionType($option) |
|
49 | 49 | { |
50 | - if ( !array_key_exists( $option, $this->properties ) ) |
|
50 | + if (!array_key_exists($option, $this->properties)) |
|
51 | 51 | { |
52 | - throw new plProcessorOptionException( $option, plProcessorOptionException::UNKNOWN ); |
|
52 | + throw new plProcessorOptionException($option, plProcessorOptionException::UNKNOWN); |
|
53 | 53 | } |
54 | 54 | return $this->properties[$option]['type']; |
55 | 55 | } |
@@ -21,17 +21,17 @@ |
||
21 | 21 | return 'image/png'; |
22 | 22 | } |
23 | 23 | |
24 | - public function execute( $infile, $outfile, $type ) |
|
24 | + public function execute($infile, $outfile, $type) |
|
25 | 25 | { |
26 | 26 | exec( |
27 | - 'neato -Tpng -o ' . escapeshellarg( $outfile ) . ' ' . escapeshellarg( $infile ), |
|
27 | + 'neato -Tpng -o ' . escapeshellarg($outfile) . ' ' . escapeshellarg($infile), |
|
28 | 28 | $output, |
29 | 29 | $return |
30 | 30 | ); |
31 | 31 | |
32 | - if ( $return !== 0 ) |
|
32 | + if ($return !== 0) |
|
33 | 33 | { |
34 | - throw new plProcessorExternalExecutionException( $output ); |
|
34 | + throw new plProcessorExternalExecutionException($output); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | { |
7 | 7 | parent::__construct( |
8 | 8 | 'To processors in the chain are incompatible. The first processor\'s output is "' |
9 | - . $first |
|
10 | - . '". The next Processor in the queue does only support the following input types: ' |
|
11 | - . implode( ', ', $second ) |
|
12 | - . '.' |
|
13 | - ); |
|
9 | + . $first |
|
10 | + . '". The next Processor in the queue does only support the following input types: ' |
|
11 | + . implode( ', ', $second ) |
|
12 | + . '.' |
|
13 | + ); |
|
14 | 14 | } |
15 | 15 | } |
16 | 16 |
@@ -2,13 +2,13 @@ |
||
2 | 2 | |
3 | 3 | class plPhumlInvalidProcessorChainException extends Exception |
4 | 4 | { |
5 | - public function __construct( $first, $second ) |
|
5 | + public function __construct($first, $second) |
|
6 | 6 | { |
7 | 7 | parent::__construct( |
8 | 8 | 'To processors in the chain are incompatible. The first processor\'s output is "' |
9 | 9 | . $first |
10 | 10 | . '". The next Processor in the queue does only support the following input types: ' |
11 | - . implode( ', ', $second ) |
|
11 | + . implode(', ', $second) |
|
12 | 12 | . '.' |
13 | 13 | ); |
14 | 14 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | { |
5 | 5 | public function __construct() |
6 | 6 | { |
7 | - parent::__construct( 'The supplied processor is invalid.' ); |
|
7 | + parent::__construct('The supplied processor is invalid.'); |
|
8 | 8 | } |
9 | 9 | } |
10 | 10 |
@@ -5,9 +5,9 @@ |
||
5 | 5 | const READ = 1; |
6 | 6 | const WRITE = 2; |
7 | 7 | |
8 | - public function __construct( $key, $type ) |
|
8 | + public function __construct($key, $type) |
|
9 | 9 | { |
10 | - parent::__construct( 'Invalid property access. The property "' . $key . '" is not '. ( $type === self::READ ? 'readable' : 'writable' ) . '.' ); |
|
10 | + parent::__construct('Invalid property access. The property "' . $key . '" is not ' . ($type === self::READ ? 'readable' : 'writable') . '.'); |
|
11 | 11 | } |
12 | 12 | } |
13 | 13 |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | class plStructureGeneratorNotFoundException extends Exception |
4 | 4 | { |
5 | - public function __construct( $generator ) |
|
5 | + public function __construct($generator) |
|
6 | 6 | { |
7 | - parent::__construct( 'The needed generator class "' . $generator . '" could not be found.' ); |
|
7 | + parent::__construct('The needed generator class "' . $generator . '" could not be found.'); |
|
8 | 8 | } |
9 | 9 | } |
10 | 10 |