@@ -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 | } |
@@ -2,17 +2,17 @@ |
||
| 2 | 2 | |
| 3 | 3 | abstract class plStructureGenerator |
| 4 | 4 | { |
| 5 | - public static function factory( $generator ) |
|
| 5 | + public static function factory($generator) |
|
| 6 | 6 | { |
| 7 | - $classname = 'plStructure' . ucfirst( $generator ) . 'Generator'; |
|
| 8 | - if ( class_exists( $classname ) === false ) |
|
| 7 | + $classname = 'plStructure' . ucfirst($generator) . 'Generator'; |
|
| 8 | + if (class_exists($classname) === false) |
|
| 9 | 9 | { |
| 10 | - throw new plStructureGeneratorNotFoundException( $generator ); |
|
| 10 | + throw new plStructureGeneratorNotFoundException($generator); |
|
| 11 | 11 | } |
| 12 | 12 | return new $classname(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public abstract function createStructure( array $files ); |
|
| 15 | + public abstract function createStructure(array $files); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | ?> |
@@ -10,38 +10,38 @@ discard block |
||
| 10 | 10 | public function __construct() |
| 11 | 11 | { |
| 12 | 12 | $this->properties = array( |
| 13 | - 'generator' => plStructureGenerator::factory( 'tokenparser' ), |
|
| 13 | + 'generator' => plStructureGenerator::factory('tokenparser'), |
|
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | 16 | $this->files = array(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function addFile( $file ) |
|
| 19 | + public function addFile($file) |
|
| 20 | 20 | { |
| 21 | 21 | $this->files[] = $file; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function addDirectory( $directory, $extension = 'php', $recursive = true ) |
|
| 24 | + public function addDirectory($directory, $extension = 'php', $recursive = true) |
|
| 25 | 25 | { |
| 26 | - if ( $recursive === false ) |
|
| 26 | + if ($recursive === false) |
|
| 27 | 27 | { |
| 28 | - $iterator = new DirectoryIterator( $directory ); |
|
| 28 | + $iterator = new DirectoryIterator($directory); |
|
| 29 | 29 | } |
| 30 | 30 | else |
| 31 | 31 | { |
| 32 | 32 | $iterator = new RecursiveIteratorIterator( |
| 33 | - new RecursiveDirectoryIterator( $directory ) |
|
| 33 | + new RecursiveDirectoryIterator($directory) |
|
| 34 | 34 | ); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - foreach( $iterator as $entry ) |
|
| 37 | + foreach ($iterator as $entry) |
|
| 38 | 38 | { |
| 39 | - if ( $entry->isDir() === true ) |
|
| 39 | + if ($entry->isDir() === true) |
|
| 40 | 40 | { |
| 41 | 41 | continue; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( $sub = strtolower( substr( $entry->getFilename(), -1 * strlen( $extension ) ) ) !== strtolower( $extension ) ) |
|
| 44 | + if ($sub = strtolower(substr($entry->getFilename(), -1 * strlen($extension))) !== strtolower($extension)) |
|
| 45 | 45 | { |
| 46 | 46 | continue; |
| 47 | 47 | } |
@@ -50,77 +50,77 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function addProcessor( $processor ) |
|
| 53 | + public function addProcessor($processor) |
|
| 54 | 54 | { |
| 55 | - if ( count( $this->processors ) === 0 ) |
|
| 55 | + if (count($this->processors) === 0) |
|
| 56 | 56 | { |
| 57 | 57 | // First processor must support application/phuml-structure |
| 58 | - if ( !in_array( 'application/phuml-structure', $processor->getInputTypes() ) ) |
|
| 58 | + if (!in_array('application/phuml-structure', $processor->getInputTypes())) |
|
| 59 | 59 | { |
| 60 | - throw new plPhumlInvalidProcessorChainException( 'application/phuml-structure', $processor->getInputTypes() ); |
|
| 60 | + throw new plPhumlInvalidProcessorChainException('application/phuml-structure', $processor->getInputTypes()); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | else |
| 64 | 64 | { |
| 65 | - $this->checkProcessorCompatibility( end( $this->processors ), $processor ); |
|
| 65 | + $this->checkProcessorCompatibility(end($this->processors), $processor); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | $this->processors[] = $processor; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - private function checkProcessorCompatibility( $first, $second ) |
|
| 71 | + private function checkProcessorCompatibility($first, $second) |
|
| 72 | 72 | { |
| 73 | - if ( !( $first instanceof plProcessor ) || !( $second instanceof plProcessor ) ) |
|
| 73 | + if (!($first instanceof plProcessor) || !($second instanceof plProcessor)) |
|
| 74 | 74 | { |
| 75 | 75 | throw new plPhumlInvalidProcessorException(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( !in_array( $first->getOutputType(), $second->getInputTypes() ) ) |
|
| 78 | + if (!in_array($first->getOutputType(), $second->getInputTypes())) |
|
| 79 | 79 | { |
| 80 | - throw new plPhumlInvalidProcessorChainException( $first->getOutputType(), $second->getInputTypes() ); |
|
| 80 | + throw new plPhumlInvalidProcessorChainException($first->getOutputType(), $second->getInputTypes()); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function generate( $outfile ) |
|
| 84 | + public function generate($outfile) |
|
| 85 | 85 | { |
| 86 | 86 | echo "[|] Parsing class structure", "\n"; |
| 87 | - $structure = $this->generator->createStructure( $this->files ); |
|
| 87 | + $structure = $this->generator->createStructure($this->files); |
|
| 88 | 88 | |
| 89 | - $temporary = array( $structure, 'application/phuml-structure' ); |
|
| 90 | - foreach( $this->processors as $processor ) |
|
| 89 | + $temporary = array($structure, 'application/phuml-structure'); |
|
| 90 | + foreach ($this->processors as $processor) |
|
| 91 | 91 | { |
| 92 | 92 | preg_match( |
| 93 | 93 | '@^pl([A-Z][a-z]*)Processor$@', |
| 94 | - get_class( $processor ), |
|
| 94 | + get_class($processor), |
|
| 95 | 95 | $matches |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | echo "[|] Running '" . $matches[1] . "' processor", "\n"; |
| 99 | 99 | $temporary = array( |
| 100 | - $processor->process( $temporary[0], $temporary[1] ), |
|
| 100 | + $processor->process($temporary[0], $temporary[1]), |
|
| 101 | 101 | $processor->getOutputType(), |
| 102 | 102 | ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | echo "[|] Writing generated data to disk", "\n"; |
| 106 | - end( $this->processors )->writeToDisk( $temporary[0], $outfile ); |
|
| 106 | + end($this->processors)->writeToDisk($temporary[0], $outfile); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - public function __get( $key ) |
|
| 110 | + public function __get($key) |
|
| 111 | 111 | { |
| 112 | - if ( !array_key_exists( $key, $this->properties ) ) |
|
| 112 | + if (!array_key_exists($key, $this->properties)) |
|
| 113 | 113 | { |
| 114 | - throw new plBasePropertyException( $key, plBasePropertyException::READ ); |
|
| 114 | + throw new plBasePropertyException($key, plBasePropertyException::READ); |
|
| 115 | 115 | } |
| 116 | 116 | return $this->properties[$key]; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - public function __set( $key, $val ) |
|
| 119 | + public function __set($key, $val) |
|
| 120 | 120 | { |
| 121 | - if ( !array_key_exists( $key, $this->properties ) ) |
|
| 121 | + if (!array_key_exists($key, $this->properties)) |
|
| 122 | 122 | { |
| 123 | - throw new plBasePropertyException( $key, plBasePropertyException::WRITE ); |
|
| 123 | + throw new plBasePropertyException($key, plBasePropertyException::WRITE); |
|
| 124 | 124 | } |
| 125 | 125 | $this->properties[$key] = $val; |
| 126 | 126 | } |
@@ -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 | } |
@@ -5,24 +5,24 @@ discard block |
||
| 5 | 5 | private static $autoload = array(); |
| 6 | 6 | private static $autoloadDirectory = array(); |
| 7 | 7 | |
| 8 | - public static function autoload( $classname ) |
|
| 8 | + public static function autoload($classname) |
|
| 9 | 9 | { |
| 10 | - if ( isset( self::$autoload[$classname] ) ) |
|
| 10 | + if (isset(self::$autoload[$classname])) |
|
| 11 | 11 | { |
| 12 | - include_once( self::$autoload[$classname] ); |
|
| 12 | + include_once(self::$autoload[$classname]); |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function addAutoloadDirectory( $directory ) |
|
| 16 | + public static function addAutoloadDirectory($directory) |
|
| 17 | 17 | { |
| 18 | - if ( !in_array( $directory, self::$autoloadDirectory ) && is_dir( $directory ) && is_readable( $directory ) ) |
|
| 18 | + if (!in_array($directory, self::$autoloadDirectory) && is_dir($directory) && is_readable($directory)) |
|
| 19 | 19 | { |
| 20 | 20 | self::$autoloadDirectory[] = $directory; |
| 21 | - foreach( $glob = glob( $directory."/*.php" ) as $file ) |
|
| 21 | + foreach ($glob = glob($directory . "/*.php") as $file) |
|
| 22 | 22 | { |
| 23 | - if ( is_array( $autoload = include( $file ) ) ) |
|
| 23 | + if (is_array($autoload = include($file))) |
|
| 24 | 24 | { |
| 25 | - self::$autoload = array_merge( $autoload, self::$autoload ); |
|
| 25 | + self::$autoload = array_merge($autoload, self::$autoload); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public static function getAutoloadClasses() |
| 32 | 32 | { |
| 33 | - return array_keys( self::$autoload ); |
|
| 33 | + return array_keys(self::$autoload); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -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 | |