diff options
Diffstat (limited to 'src/Support/Permissions.php')
-rw-r--r-- | src/Support/Permissions.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Support/Permissions.php b/src/Support/Permissions.php new file mode 100644 index 0000000..daabf5a --- /dev/null +++ b/src/Support/Permissions.php @@ -0,0 +1,28 @@ +<?php + +namespace PHPIAC\Modules\Support; + +class Permissions +{ + public function __construct( + protected string $path, + protected string $owner = '', + protected string $group = '', + protected int $mode = 0, + ) {} + + public function __toString(): string + { + $permissions = []; + + if (! empty($this->owner) || ! empty($this->group)) { + $permissions[] = "sudo chown -R $this->owner:$this->group $this->path"; + } + + if (! empty($this->mode)) { + $permissions[] = "sudo chmod -R $this->mode $this->path"; + } + + return implode(PHP_EOL, $permissions); + } +} |