This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
| Q | A | --------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | fixes #92,fixes #93 | License | MIT | Doc PR | -
- Loading branch information
Showing
59 changed files
with
425 additions
and
355 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace Narrowspark\Automatic\Configurator\Traits; | ||
|
||
use Symfony\Component\Filesystem\Exception\IOException; | ||
|
||
trait AppendToFileTrait | ||
{ | ||
/** | ||
* Appends content to an existing file. | ||
* | ||
* @see \Symfony\Component\Filesystem\Filesystem::appendToFile() | ||
* | ||
* @param string $filename The file to which to append content | ||
* @param string $content The content to append | ||
* | ||
* @throws IOException If the file is not writable | ||
* | ||
* @return void | ||
*/ | ||
public function appendToFile(string $filename, string $content): void | ||
{ | ||
if (\method_exists($this->filesystem, 'appendToFile')) { | ||
$this->filesystem->appendToFile($filename, $content); | ||
|
||
return; | ||
} | ||
// @codeCoverageIgnoreStart | ||
$dir = \dirname($filename); | ||
|
||
if (! \is_dir($dir)) { | ||
$this->filesystem->mkdir($dir); | ||
} | ||
|
||
if (! \is_writable($dir)) { | ||
throw new IOException(\sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); | ||
} | ||
|
||
if (false === @\file_put_contents($filename, $content, \FILE_APPEND)) { | ||
throw new IOException(\sprintf('Failed to write file "%s".', $filename), 0, null, $filename); | ||
} | ||
// @codeCoverageIgnoreEnd | ||
} | ||
} |
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
Oops, something went wrong.