Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Erickson committed Jun 24, 2020
2 parents 7b7320c + 7e6127d commit bc023b0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
29 changes: 15 additions & 14 deletions src/PrinterInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -79,13 +79,14 @@ private function add_collision_to_phpunit_xml(string $file = './phpunit.xml'): i
</listeners>
';
$data = file_get_contents($file);
$pos = strpos($data, "Collision");
$pos = strpos($data, 'Collision');
if (!$pos) {
$pos = strpos($data, "<filter>");
$pos = strpos($data, '<filter>');
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;
}
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/PrinterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public function version()
/**
* @return string
*/
public function getVersion() {
public function getVersion()
{
return $this->version();
}

Expand Down
3 changes: 2 additions & 1 deletion src/PrinterTrait8.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ public function version()
/**
* @return string
*/
public function getVersion() {
public function getVersion()
{
return $this->version();
}

Expand Down
2 changes: 1 addition & 1 deletion src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

require_once 'PrinterInit.php';

(new PrinterInit)->init('always',$_SERVER["argv"]);
(new PrinterInit())->init('always', $_SERVER['argv']);

0 comments on commit bc023b0

Please sign in to comment.