summaryrefslogtreecommitdiff
path: root/src/GitModule.php
blob: 39112a2e6a1629de9f3856c27ff6299f77b244f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

namespace PHPIAC\Modules;

use PHPIAC\Connection;
use PHPIAC\Module\Module;
use PHPIAC\Modules\Support\HandlesFiles;
use PHPIAC\Modules\Support\HasPermissions;

class GitModule extends Module
{
    use HasPermissions, HandlesFiles;

    protected string $repo;
    protected string $dest;

    /**
     * @inheritDoc
     */
    public function checkState(): bool
    {
        return $this->fileExists($this->dest);
    }

    /**
     * @inheritDoc
     */
    public function execute(): void
    {
        Connection::exec(
            "sudo git clone $this->repo $this->dest" . PHP_EOL .
            $this->getPermissions($this->dest)
        );
    }
}