forked from sroze/companienv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] includes needed classes of "jackiedo/dotenv-editor" locally…
… to reduce dependencies [TASK] refactores Companion and DotEnv/* classes [TASK] adds/ updates test cases
- Loading branch information
Showing
22 changed files
with
1,305 additions
and
16 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
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
37 changes: 37 additions & 0 deletions
37
src/Companienv/DotEnvEditor/Contracts/FormatterInterface.php
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,37 @@ | ||
<?php | ||
|
||
namespace Companienv\DotEnvEditor\Contracts; | ||
|
||
interface FormatterInterface | ||
{ | ||
/** | ||
* Formatting the key of setter to writing. | ||
* | ||
* @param string $key | ||
* @param bool $export optional | ||
* | ||
* @return string | ||
*/ | ||
public function formatKey(string $key, bool $export = false); | ||
|
||
/** | ||
* Build an setter from the individual components for writing. | ||
* | ||
* @param string $key | ||
* @param string|null $value optional | ||
* @param string|null $comment optional | ||
* @param bool $export optional | ||
* | ||
* @return string | ||
*/ | ||
public function formatSetter(string $key, ?string $value = null, ?string $comment = null, bool $export = false); | ||
|
||
/** | ||
* Formatting the comment to writing. | ||
* | ||
* @param string $comment | ||
* | ||
* @return string | ||
*/ | ||
public function formatComment(?string $comment); | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Companienv\DotEnvEditor\Contracts; | ||
|
||
interface ParserInterface | ||
{ | ||
/** | ||
* Parse dotenv file content into separate entries. | ||
* | ||
* This will produce an array of entries, each entry | ||
* being an informational array of starting line and raw data. | ||
* | ||
* @param string $filePath The path to dotenv file | ||
* | ||
* @return array<int, mixed[]> | ||
*/ | ||
public function parseFile(string $filePath): array; | ||
|
||
/** | ||
* Parses an entry data into an array of type, export allowed or not, | ||
* key, value, and comment information. | ||
* | ||
* @param string $data The entry data | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function parseEntry(string $data): array; | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace Companienv\DotEnvEditor\Contracts; | ||
|
||
interface ReaderInterface | ||
{ | ||
/** | ||
* Load .env file. | ||
* | ||
* @param string $filePath The path to dotenv file | ||
*/ | ||
public function load(string $filePath): self; | ||
|
||
/** | ||
* Get content of .env file. | ||
*/ | ||
public function content(): string; | ||
|
||
/** | ||
* Get information of all entries from file content. | ||
* | ||
* @param bool $withParsedData Includes the parsed data in the result | ||
* @return mixed[] | ||
*/ | ||
public function entries(bool $withParsedData = false): array; | ||
|
||
/** | ||
* Get all key information in .env file. | ||
* | ||
* @return mixed[] | ||
*/ | ||
public function keys(): array; | ||
} |
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,73 @@ | ||
<?php | ||
|
||
namespace Companienv\DotEnvEditor\Contracts; | ||
|
||
interface WriterInterface | ||
{ | ||
/** | ||
* Load current content into buffer. | ||
* | ||
* @param array<int, mixed[]> $content | ||
*/ | ||
public function setBuffer(array $content): self; | ||
|
||
/** | ||
* Return content in buffer. | ||
* | ||
* @return array<int, mixed[]> | ||
*/ | ||
public function getBuffer(): array; | ||
|
||
/** | ||
* Return content in buffer. | ||
* | ||
* @return string | ||
*/ | ||
public function getBufferAsString(): string; | ||
|
||
/** | ||
* Append empty line to buffer. | ||
*/ | ||
public function appendEmpty(): self; | ||
|
||
/** | ||
* Append comment line to buffer. | ||
* | ||
* @param string $comment | ||
*/ | ||
public function appendComment(string $comment): self; | ||
|
||
/** | ||
* Append one setter to buffer. | ||
* | ||
* @param string $key | ||
* @param string|null $value | ||
* @param string|null $comment | ||
* @param bool $export | ||
*/ | ||
public function appendSetter(string $key, ?string $value = null, ?string $comment = null, bool $export = false): self; | ||
|
||
/** | ||
* Update one setter in buffer. | ||
* | ||
* @param string $key | ||
* @param string|null $value | ||
* @param string|null $comment | ||
* @param bool $export | ||
*/ | ||
public function updateSetter(string $key, ?string $value = null, ?string $comment = null, bool $export = false): self; | ||
|
||
/** | ||
* Delete one setter in buffer. | ||
* | ||
* @param string $key | ||
*/ | ||
public function deleteSetter(string $key): self; | ||
|
||
/** | ||
* Save buffer to special file. | ||
* | ||
* @param string $filePath | ||
*/ | ||
public function saveTo(string $filePath): self; | ||
} |
Oops, something went wrong.