Skip to content

Commit

Permalink
Fix: Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 3, 2023
1 parent 1ecacf8 commit b235726
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 847 deletions.
14 changes: 7 additions & 7 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
use PHPUnit\Util;

try {
$phpUnitVersion = Version\Version::fromString(Runner\Version::id());
$phpUnitVersionSeries = Version\Series::fromString(Runner\Version::series());

Check warning on line 21 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L21

Added line #L21 was not covered by tests
} catch (\InvalidArgumentException $exception) {
throw new \RuntimeException(\sprintf(
'Unable to determine PHPUnit version from version identifier "%s".',
Runner\Version::id(),
'Unable to determine PHPUnit version from version series "%s".',
Runner\Version::series(),

Check warning on line 25 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L24-L25

Added lines #L24 - L25 were not covered by tests
));
}

if ($phpUnitVersion->major()->equals(Version\Major::fromInt(9))) {
if ($phpUnitVersionSeries->major()->equals(Version\Major::fromInt(9))) {

Check warning on line 29 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L29

Added line #L29 was not covered by tests
/**
* @internal
*/
Expand Down Expand Up @@ -166,7 +166,7 @@ private function resolveMaximumDuration(string $test): Duration
return $this->maximumDuration;
}
}
} elseif ($phpUnitVersion->major()->equals(Version\Major::fromInt(10))) {
} elseif ($phpUnitVersionSeries->major()->equals(Version\Major::fromInt(10))) {

Check warning on line 169 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L169

Added line #L169 was not covered by tests
/**
* @internal
*/
Expand Down Expand Up @@ -217,7 +217,7 @@ public function bootstrap(
}
} else {
throw new \RuntimeException(\sprintf(
'Unable to select extension for PHPUnit version with version identifier "%s".',
Runner\Version::id(),
'Unable to select extension for PHPUnit version with version series "%s".',
Runner\Version::series(),

Check warning on line 221 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L220-L221

Added lines #L220 - L221 were not covered by tests
));
}
47 changes: 0 additions & 47 deletions src/Version/Minor.php

This file was deleted.

47 changes: 0 additions & 47 deletions src/Version/Patch.php

This file was deleted.

54 changes: 54 additions & 0 deletions src/Version/Series.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021-2023 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

namespace Ergebnis\PHPUnit\SlowTestDetector\Version;

/**
* @internal
*/
final class Series
{
private Major $major;

private function __construct(Major $major)
{
$this->major = $major;
}

public static function create(Major $major): self
{
return new self($major);
}

/**
* @throws \InvalidArgumentException
*/
public static function fromString(string $value): self
{
if (0 === \preg_match('/^(?P<major>(0|[1-9]\d*))\.(?P<minor>(0|[1-9]\d*))?$/', $value, $matches)) {
throw new \InvalidArgumentException(\sprintf(
'Value "%s" does not appear to be a valid value for a semantic version.',
$value,
));
}

$major = Major::fromInt((int) $matches['major']);

return self::create($major);
}

public function major(): Major
{
return $this->major;
}
}
183 changes: 0 additions & 183 deletions src/Version/Version.php

This file was deleted.

Loading

0 comments on commit b235726

Please sign in to comment.