-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
111 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,55 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: miles | ||
* Date: 19/12/15 | ||
* Time: 11:32 | ||
*/ | ||
|
||
namespace M1\Vars\Traits; | ||
|
||
trait PathTrait | ||
{ | ||
/** | ||
* The base path for the Vars config and cache folders | ||
* | ||
* @var string $path | ||
*/ | ||
public $path; | ||
|
||
/** | ||
* Get the path | ||
* | ||
* @return string The path | ||
*/ | ||
public function getPath() | ||
{ | ||
return $this->path; | ||
} | ||
|
||
/** | ||
* Set the Vars base path | ||
* | ||
* @param string $path The path to set | ||
* | ||
* @throws \InvalidArgumentException If the path does not exist or is not writable | ||
* | ||
* @return \M1\Vars\Vars | ||
*/ | ||
public function setPath($path, $check_writeable = false) | ||
{ | ||
if (is_null($path)) { | ||
return; | ||
} | ||
|
||
if (!is_dir($path) || ($check_writeable && !is_writable($path))) { | ||
throw new \InvalidArgumentException(sprintf( | ||
"'%s' base path does not exist or is not writable", | ||
$path | ||
)); | ||
} | ||
|
||
$this->path = realpath($path); | ||
return $this; | ||
} | ||
} |
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