diff --git a/src/Analyzer.php b/src/Analyzer.php index d519bf8a6134a3bbe2538caf4feedddf9520cead..361a30348b87a6ed2dbe4fb376c815354fd33caf 100644 --- a/src/Analyzer.php +++ b/src/Analyzer.php @@ -1,54 +1,54 @@ <?php +namespace Analyzer; - class Analyzer{ - - private $fileName; - private $fileContent; - - function __construct(){} - - function __destruct(){} - - public function analyze($pFileName){ - if(!$pFileName || !is_string($pFileName)){ - $this->kill("No file"); - } - else{ - $this->fileName= $pFileName; - $this->fileContent = file_get_contents($this->fileName); - } +class Analyzer +{ + + private $fileName; + private $fileContent; + + public function analyze($pFileName) + { + if (!$pFileName || !is_string($pFileName)) { + $this->kill("No file"); + } else { + $this->fileName= $pFileName; + $this->fileContent = file_get_contents($this->fileName); } - - - /** - * //FIXME kill properly - * @param string $message - */ - private function kill($message){ - die($message); - } - - /** - * Searches for non-ASCII characters, often used in obfuscated files - * @return number - */ - private function searchNonASCIIChars(){ - $count = 0; - for($i = 0; $i < strlen($this->fileContent); $i++){ - if (ord($this->fileContent[$i]) > 0x7f){ - $count++; - } + } + + + /** + * //FIXME kill properly + * @param string $message + */ + private function kill($message) + { + die($message); + } + + /** + * Searches for non-ASCII characters, often used in obfuscated files + * @return number + */ + private function searchNonASCIIChars() + { + $count = 0; + for ($i = 0; $i < strlen($this->fileContent); $i++) { + if (ord($this->fileContent[$i]) > 0x7f) { + $count++; } - return $count/strlen($this->fileContent); - } - - /** - * Wrapper for tests - * @param $func - * @return ? value of the called function - */ - public function testMe($func){ - return $this->$func(); } + return $count/strlen($this->fileContent); + } + + /** + * Wrapper for tests + * @param $func + * @return ? value of the called function + */ + public function testMe($func) + { + return $this->$func(); } - \ No newline at end of file +} diff --git a/src/test.php b/src/test.php index 32a89f2a04af54e66c700d2c0a421006c70d466b..53432364af8eb3bab16fca5475df8da2923245b8 100644 --- a/src/test.php +++ b/src/test.php @@ -1,4 +1,3 @@ <?php $Æ = "test"; echo $Æ; -?> \ No newline at end of file diff --git a/src/util.php b/src/util.php index d0d4b5ec8a64caa01b625e9c019ab1ff2f2e8fb2..3d19c74d746dec7fc8def7b26e3528c129126a57 100644 --- a/src/util.php +++ b/src/util.php @@ -1,18 +1,19 @@ <?php - /** - * Apply the strpos function with an array of parameters - * @param string $haystack - * @param array $arrayOfWords words to search in the haystack - * @return int|boolean - */ - function strposOnArray($haystack, $arrayOfWords){ - if (is_array($arrayOfWords)) { - foreach ($arrayOfWords as $word) { - $pos = strpos($haystack, $word); - if ($pos !== false) { - return $pos; - } +/** + * Apply the strpos function with an array of parameters + * @param string $haystack + * @param array $arrayOfWords words to search in the haystack + * @return int|boolean + */ +function strposOnArray($haystack, $arrayOfWords) +{ + if (is_array($arrayOfWords)) { + foreach ($arrayOfWords as $word) { + $pos = strpos($haystack, $word); + if ($pos !== false) { + return $pos; } - return false; } - } \ No newline at end of file + return false; + } +} diff --git a/tests/AnalyzerTest.php b/tests/AnalyzerTest.php index 639d405ad477223c45643780852da621a671dc95..c0ecdcdc61bafe891585de8fdd3013a648b3c3ea 100644 --- a/tests/AnalyzerTest.php +++ b/tests/AnalyzerTest.php @@ -1,14 +1,18 @@ <?php - namespace Tests; - use PHPUnit\Framework\TestCase; - require_once '../src/Analyzer.php'; +namespace Tests; + +use PHPUnit\Framework\TestCase; +use Analyzer\Analyzer; + +require_once '../src/Analyzer.php'; + +class AnalyzerTest extends TestCase +{ - class AnalyzerTest extends TestCase{ - - public function testTestMe(){ - $analyzer = new \Analyzer(); - $analyzer->analyze("../src/test.php"); - $this->assertTrue($analyzer->testMe("searchNonASCIIChars") >0); - } + public function testTestMe() + { + $analyzer = new Analyzer(); + $analyzer->analyze("../src/test.php"); + $this->assertTrue($analyzer->testMe("searchNonASCIIChars") >0); } -?> \ No newline at end of file +}