From 7e6127d7cf45e8f45ee9c0ca3470eaf80df91a82 Mon Sep 17 00:00:00 2001 From: Mike Erickson Date: Tue, 23 Jun 2020 17:15:36 -0700 Subject: [PATCH] Apply fixes from StyleCI (#163) --- src/PrinterInit.php | 29 +++++++++++++++-------------- src/PrinterTrait.php | 3 ++- src/PrinterTrait8.php | 3 ++- src/init.php | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/PrinterInit.php b/src/PrinterInit.php index 95dc02c..640714a 100755 --- a/src/PrinterInit.php +++ b/src/PrinterInit.php @@ -2,14 +2,14 @@ class PrinterInit { - const GREEN = "\e[32m"; - const RESET = "\e[0m"; - const CYAN = "\e[36m"; - const RED = "\e[31m"; - const YELLOW = "\033[0;33m"; + const GREEN = "\e[32m"; + const RESET = "\e[0m"; + const CYAN = "\e[36m"; + const RED = "\e[31m"; + const YELLOW = "\033[0;33m"; const LYELLOW = "\033[33;01m"; - const WHITE = "\033[0;37m"; - const LWHITE = "\033[37;01m"; + const WHITE = "\033[0;37m"; + const LWHITE = "\033[37;01m"; const MAGENTA = "\033[2;35m"; public function __construct() @@ -20,7 +20,7 @@ public function init(string $use_colors = 'never', array $options = []): int { $result = 0; - $useCollision = in_array("--collision", $options); + $useCollision = in_array('--collision', $options); $phpunit_xml_file = './phpunit.xml'; if (!file_exists($phpunit_xml_file)) { @@ -30,7 +30,7 @@ public function init(string $use_colors = 'never', array $options = []): int echo "\n ".self::LWHITE.'[• ]'.self::GREEN." Gathering installation details\n".self::RESET; $result = $this->add_printer_class_to_phpunit_xml($phpunit_xml_file); if ($useCollision) { - if (is_dir("vendor/nunomaduro/collision")) { + if (is_dir('vendor/nunomaduro/collision')) { $result = $this->add_collision_to_phpunit_xml($phpunit_xml_file); if ($result === 0) { echo self::GREEN." ✔ Collision listener activated\n".self::RESET; @@ -51,7 +51,7 @@ private function add_printer_class_to_phpunit_xml(string $file = './phpunit.xml' { $PHPUNIT_FILE = $file; if (file_exists($PHPUNIT_FILE)) { - $data = file_get_contents($PHPUNIT_FILE); + $data = file_get_contents($PHPUNIT_FILE); $result = (int) strpos($data, 'printerClass='); if ($result > 0) { echo self::LWHITE.' [•• ]'.self::LYELLOW.' Printer class already configured in '.self::CYAN."{$PHPUNIT_FILE} \n".self::RESET; @@ -79,13 +79,14 @@ private function add_collision_to_phpunit_xml(string $file = './phpunit.xml'): i '; $data = file_get_contents($file); - $pos = strpos($data, "Collision"); + $pos = strpos($data, 'Collision'); if (!$pos) { - $pos = strpos($data, ""); + $pos = strpos($data, ''); if ($pos > 0) { $data = substr_replace($data, $collisionData, $pos, 0); file_put_contents($file, $data); - return 0;//all good, no errors + + return 0; //all good, no errors } else { return -43; } @@ -96,7 +97,7 @@ private function add_collision_to_phpunit_xml(string $file = './phpunit.xml'): i private function copy_default_settings(string $file = 'phpunit-printer.yml') { - $CONFIG_FILE = $file; + $CONFIG_FILE = $file; $packageDefaultSettingFile = dirname(__FILE__, 2).DIRECTORY_SEPARATOR.'src/'.$CONFIG_FILE; $copySettingFile = $CONFIG_FILE; diff --git a/src/PrinterTrait.php b/src/PrinterTrait.php index 326ad85..9022537 100755 --- a/src/PrinterTrait.php +++ b/src/PrinterTrait.php @@ -143,7 +143,8 @@ public function version() /** * @return string */ - public function getVersion() { + public function getVersion() + { return $this->version(); } diff --git a/src/PrinterTrait8.php b/src/PrinterTrait8.php index 20097d5..72bf1f6 100644 --- a/src/PrinterTrait8.php +++ b/src/PrinterTrait8.php @@ -139,7 +139,8 @@ public function version() /** * @return string */ - public function getVersion() { + public function getVersion() + { return $this->version(); } diff --git a/src/init.php b/src/init.php index 653194f..776d6b0 100755 --- a/src/init.php +++ b/src/init.php @@ -2,4 +2,4 @@ require_once 'PrinterInit.php'; -(new PrinterInit)->init('always',$_SERVER["argv"]); +(new PrinterInit())->init('always', $_SERVER['argv']);