-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow config and temp directories to be configured independently.
- Loading branch information
1 parent
26a70c2
commit b653141
Showing
11 changed files
with
258 additions
and
72 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
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
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
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,56 @@ | ||
<?php | ||
|
||
namespace Knuckles\Scribe\Configuration; | ||
|
||
/** | ||
* A home for path configurations. | ||
*/ | ||
class PathConfig | ||
{ | ||
/** @var string */ | ||
private string $scribeConfig; | ||
|
||
/** @var string */ | ||
private string $cacheDir; | ||
|
||
/** @var bool */ | ||
private bool $isHidden; | ||
|
||
/** | ||
* @param string $cacheDir | ||
* @param string $scribeConfig | ||
* @param bool $isHidden | ||
*/ | ||
public function __construct(string $cacheDir, string$scribeConfig, bool $isHidden = true) | ||
{ | ||
$this->cacheDir = $cacheDir; | ||
$this->scribeConfig = $scribeConfig; | ||
$this->isHidden = $isHidden; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getScribeConfigurationPath(string $resolvePath = null, string $separator = '/'): string | ||
{ | ||
if (is_null($resolvePath)) { | ||
return $this->scribeConfig; | ||
} | ||
// Separate the path with a / | ||
return sprintf("%s%s%s", $this->scribeConfig, $separator, $resolvePath); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTemporaryDirectoryPath(string $resolvePath = null): string | ||
{ | ||
$path = ($this->isHidden ? '.' : '') . $this->cacheDir; | ||
if (is_null($resolvePath)) { | ||
return $path; | ||
} | ||
// Separate the path with a / | ||
return sprintf("%s/%s", $path, $resolvePath); | ||
|
||
} | ||
} |
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
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
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
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
Oops, something went wrong.