Skip to content

Commit 7309ba6

Browse files
committed
Code quality improvements
1 parent 6296137 commit 7309ba6

File tree

10 files changed

+176
-159
lines changed

10 files changed

+176
-159
lines changed

FileIterator.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace MaplePHP\Unitary;
@@ -13,7 +14,7 @@
1314

1415
class FileIterator
1516
{
16-
const PATTERN = 'unitary-*.php';
17+
public const PATTERN = 'unitary-*.php';
1718

1819
private array $args;
1920

@@ -74,7 +75,7 @@ private function findFiles(string $dir): array
7475
$pattern = static::PATTERN;
7576
foreach ($iterator as $file) {
7677
if (($file instanceof SplFileInfo) && fnmatch($pattern, $file->getFilename()) &&
77-
(isset($this->args['path']) || !str_contains($file->getPathname(), DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR ))) {
78+
(isset($this->args['path']) || !str_contains($file->getPathname(), DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR))) {
7879
if(!$this->findExcluded($this->exclude(), $dir, $file->getPathname())) {
7980
$files[] = $file->getPathname();
8081
}
@@ -87,9 +88,9 @@ private function findFiles(string $dir): array
8788
* Get exclude parameter
8889
* @return array
8990
*/
90-
function exclude(): array
91+
public function exclude(): array
9192
{
92-
$excl = array();
93+
$excl = [];
9394
if(isset($this->args['exclude']) && is_string($this->args['exclude'])) {
9495
$exclude = explode(',', $this->args['exclude']);
9596
foreach ($exclude as $file) {
@@ -112,7 +113,7 @@ function exclude(): array
112113
* @param string $file
113114
* @return bool
114115
*/
115-
function findExcluded(array $exclArr, string $relativeDir, string $file): bool
116+
public function findExcluded(array $exclArr, string $relativeDir, string $file): bool
116117
{
117118
$file = $this->getNaturalPath($file);
118119
foreach ($exclArr as $excl) {
@@ -129,7 +130,7 @@ function findExcluded(array $exclArr, string $relativeDir, string $file): bool
129130
* @param string $path
130131
* @return string
131132
*/
132-
function getNaturalPath(string $path): string
133+
public function getNaturalPath(string $path): string
133134
{
134135
return str_replace("\\", "/", $path);
135136
}
@@ -142,8 +143,7 @@ function getNaturalPath(string $path): string
142143
private function requireUnitFile(string $file): ?Closure
143144
{
144145
$clone = clone $this;
145-
$call = function() use ($file, $clone): void
146-
{
146+
$call = function () use ($file, $clone): void {
147147
$cli = new CliHandler();
148148
if(isset(self::$headers['args']['trace'])) {
149149
$cli->enableTraceLines(true);
@@ -155,7 +155,7 @@ private function requireUnitFile(string $file): ?Closure
155155
if (!is_file($file)) {
156156
throw new RuntimeException("File \"$file\" do not exists.");
157157
}
158-
require_once ($file);
158+
require_once($file);
159159

160160
$clone->getUnit()->execute();
161161

@@ -180,4 +180,4 @@ protected function getUnit(): Unit
180180
return $unit;
181181

182182
}
183-
}
183+
}

Handlers/FileHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace MaplePHP\Unitary\Handlers;
@@ -45,4 +46,4 @@ public function execute(): void
4546
$upload = new UploadedFile($this->stream);
4647
$upload->moveTo($this->file);
4748
}
48-
}
49+
}

Handlers/HandlerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace MaplePHP\Unitary\Handlers;
@@ -7,7 +8,6 @@
78

89
interface HandlerInterface
910
{
10-
1111
/**
1212
* Access the command stream
1313
* @return Command
@@ -20,4 +20,4 @@ public function getCommand(): Command;
2020
* @return void
2121
*/
2222
public function execute(): void;
23-
}
23+
}

Handlers/HtmlHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace MaplePHP\Unitary\Handlers;
@@ -44,4 +45,4 @@ public function execute(): void
4445
$out = str_replace(["[", "]"], ['<span style="background-color: #666; color: #FFF; padding: 4px 2px">', '</span>'], $out);
4546
echo '<pre style="' . $style . '">' . $out . '</pre>';
4647
}
47-
}
48+
}

0 commit comments

Comments
 (0)