Skip to content

Commit

Permalink
Update namesapces. Context for shell vs project
Browse files Browse the repository at this point in the history
  • Loading branch information
omahm committed Sep 26, 2022
1 parent 8e84bdb commit 6d52789
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/Context.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Maestro\Core;

enum Context {
case Maestro;
case Project;
}

19 changes: 12 additions & 7 deletions src/Filesystem.php → src/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maestro\Core;
namespace Maestro\Core\Filesystem;

/**
* Provides basic filesystem functions.
Expand Down Expand Up @@ -65,7 +65,7 @@ public function read($path) {
* The contents to write to the file.
*/
public function write($path, $content) {
return $this->fs->dumpFile($this->fullPath($path), $content);
$this->fs->dumpFile($this->fullPath($path), $content);
}

/**
Expand All @@ -75,7 +75,7 @@ public function write($path, $content) {
* The path to the file or directory.
*/
public function delete($path) {
return $this->fs->remove($this->fullPath($path));
$this->fs->remove($this->fullPath($path));
}

/**
Expand All @@ -88,9 +88,9 @@ public function delete($path) {
*/
public function copy($path, $destination) {
if ($this->isDir($path)) {
return $this->fs->mirror($this->fullPath($path), $this->fullPath($destination));
$this->fs->mirror($this->fullPath($path), $this->fullPath($destination));
} else {
return $this->fs->copy($this->fullPath($path), $this->fullPath($destination));
$this->fs->copy($this->fullPath($path), $this->fullPath($destination));
}
}

Expand All @@ -101,7 +101,7 @@ public function copy($path, $destination) {
* The path of the directory.
*/
public function createDirectory($path) {
return $this->fs->mkdir($this->fullPath($path));
$this->fs->mkdir($this->fullPath($path));
}

/**
Expand All @@ -113,7 +113,7 @@ public function createDirectory($path) {
* The name of the symlink.
*/
public function link($source, $link) {
return $this->fs->symlink($this->fullPath($source), $this->fullPath($link));
$this->fs->symlink($this->fullPath($source), $this->fullPath($link));
}

/**
Expand Down Expand Up @@ -145,6 +145,11 @@ public function setRootPath($path) {
* The full root and path.
*/
protected function fullPath($path) {
// If the path starts with a double slash do not prepend the rootPath.
if (str_starts_with($path, '//')) {
return substr($path, 1, strlen($path));
}

return $this->rootPath . $path;
}
}
6 changes: 3 additions & 3 deletions src/HostingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Maestro\Core;

use League\Flysystem\FilesystemAdapter;
use Maestro\Core\Filesystem\Filesystem;
use Symfony\Component\Console\Style\StyleInterface;

/**
Expand All @@ -15,12 +15,12 @@ interface HostingInterface {
*
* @param \Symfony\Component\Console\Style\StyleInterface $io
* Symfony style instance.
* @param \League\Flysystem\FilesystemAdapter $fs
* @param \Maestro\Core\Filesystem\Filesystem $fs
* Filesystem instance.
* @param \Maestro\Core\ProjectInterface $project
* Filesystem instance.
*/
public function build(StyleInterface $io, FilesystemAdapter $fs, ProjectInterface $project);
public function build(StyleInterface $io, Filesystem $fs, ProjectInterface $project);

/**
* Service name.
Expand Down

0 comments on commit 6d52789

Please sign in to comment.