generated from ghostwriter/wip
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
- Loading branch information
1 parent
357de44
commit 9045ee7
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ghostwriter\Arm; | ||
|
||
use Ghostwriter\Arm\Interface\WorkspaceInterface; | ||
use Ghostwriter\Arm\Service\Factory\WorkspaceFactory; | ||
use Ghostwriter\Container\Attribute\Factory; | ||
use InvalidArgumentException; | ||
use Override; | ||
|
||
use function is_dir; | ||
use function trim; | ||
|
||
#[Factory(WorkspaceFactory::class)] | ||
final readonly class Workspace implements WorkspaceInterface | ||
{ | ||
public function __construct( | ||
private string $workspace | ||
) { | ||
if (trim($workspace) === '') { | ||
throw new InvalidArgumentException('Workspace cannot be empty'); | ||
} | ||
|
||
if (! is_dir($workspace)) { | ||
throw new InvalidArgumentException('Workspace must be a directory'); | ||
} | ||
} | ||
|
||
#[Override] | ||
public function toString(): string | ||
{ | ||
return $this->workspace; | ||
} | ||
|
||
#[Override] | ||
public static function new(string $workspace): self | ||
{ | ||
return new self($workspace); | ||
} | ||
} |