Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
- `Innmind\Server\Status\Exception\EmptyUserNotAllowed`
- `Innmind\Server\Status\Exception\LoadAverageCannotBeNegative`
- `Innmind\Server\Status\Exception\DomainException`
- `Innmind\Server\Status\Exception\UnsupportedOperatingSystem`
- `Innmind\Server\Status\Exception\RuntimeException`
- `Innmind\Server\Status\Exception\Exception`

## 4.1.1 - 2024-09-30

Expand Down
8 changes: 0 additions & 8 deletions src/Exception/Exception.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Exception/RuntimeException.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Exception/UnsupportedOperatingSystem.php

This file was deleted.

24 changes: 8 additions & 16 deletions src/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,24 @@

namespace Innmind\Server\Status;

use Innmind\Server\Status\{
Servers\OSX,
Servers\Linux,
Exception\UnsupportedOperatingSystem,
use Innmind\Server\Status\Servers\{
OSX,
Linux,
};
use Innmind\Server\Control\Server as Control;
use Innmind\TimeContinuum\Clock;

final class ServerFactory
{
/**
* @throws UnsupportedOperatingSystem
*/
public static function build(
Clock $clock,
Control $control,
EnvironmentPath $path,
): Server {
switch (\PHP_OS) {
case 'Darwin':
return new OSX($clock, $control, $path);

case 'Linux':
return new Linux($clock, $control);
}

throw new UnsupportedOperatingSystem;
return match (\PHP_OS) {
'Darwin' => new OSX($clock, $control, $path),
'Linux' => new Linux($clock, $control),
default => throw new \LogicException('Unsupported operating system '.\PHP_OS),
};
}
}