-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase testability breaking change: config('paths.backupDirectory') need to use storage_path() function
- Loading branch information
Showing
13 changed files
with
361 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
} | ||
], | ||
"require": { | ||
"php": "^7|^8", | ||
"php": "^8", | ||
"laravel/framework": "^8|^9" | ||
}, | ||
"require-dev": { | ||
|
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,96 @@ | ||
<?php | ||
|
||
namespace GeoSot\EnvEditor\Helpers; | ||
|
||
use Illuminate\Support\Arr; | ||
|
||
class EntryObj implements \JsonSerializable | ||
{ | ||
public string $key; | ||
|
||
/** | ||
* @var int|string|null | ||
*/ | ||
protected mixed $value; | ||
|
||
public int $group = 0; | ||
|
||
public int $index = 0; | ||
|
||
protected bool $isSeparator = false; | ||
|
||
/** | ||
* @param string $key | ||
* @param int|string|null $value | ||
* @param int $group | ||
* @param int $index | ||
* @param bool $isSeparator | ||
*/ | ||
public function __construct(string $key, mixed $value, int $group, int $index, bool $isSeparator = false) | ||
{ | ||
$this->key = $key; | ||
$this->value = $value; | ||
$this->group = $group; | ||
$this->index = $index; | ||
$this->isSeparator = $isSeparator; | ||
} | ||
|
||
public static function parseEnvLine(string $line, int $group, int $index): self | ||
{ | ||
$entry = explode('=', $line, 2); | ||
$isSeparator = count($entry) === 1; | ||
|
||
return new self(Arr::get($entry, 0), Arr::get($entry, 1), $group, $index, $isSeparator); | ||
} | ||
|
||
public static function makeKeysSeparator(int $groupIndex, int $index): self | ||
{ | ||
return new self('', '', $groupIndex, $index, true); | ||
} | ||
|
||
public function getAsEnvLine(): string | ||
{ | ||
return $this->isSeparator() ? '' : "$this->key=$this->value"; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isSeparator(): bool | ||
{ | ||
return $this->isSeparator; | ||
} | ||
|
||
/** | ||
* @param mixed $default | ||
* @return int|string|null|mixed | ||
*/ | ||
public function getValue(mixed $default = null): mixed | ||
{ | ||
return $this->value ?: $default; | ||
} | ||
|
||
/** | ||
* @param int|string|null|mixed $value | ||
*/ | ||
public function setValue(mixed $value): void | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @return array{key:string, value: int|string|null, group:int, index:int , isSeparator:bool} | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return get_object_vars($this); | ||
} | ||
|
||
/** | ||
* @return array{key:string, value: int|string|null, group:int, index:int , isSeparator:bool} | ||
*/ | ||
public function jsonSerialize(): array | ||
{ | ||
return $this->toArray(); | ||
} | ||
} |
Oops, something went wrong.