| 1 |
<?php |
| 2 |
|
| 3 |
namespace Shellbox\Command; |
| 4 |
|
| 5 |
use Shellbox\FileUtils; |
| 6 |
|
| 7 |
/** |
| 8 |
* Encapsulation of an input file that comes from a string |
| 9 |
*/ |
| 10 |
class InputFileFromString extends InputFileWithContents { |
| 11 |
/** @var string */ |
| 12 |
private $contents; |
| 13 |
|
| 14 |
/** |
| 15 |
* @internal |
| 16 |
* @param string $contents |
| 17 |
*/ |
| 18 |
public function __construct( string $contents ) { |
| 19 |
$this->contents = $contents; |
| 20 |
} |
| 21 |
|
| 22 |
public function copyTo( $destPath ) { |
| 23 |
FileUtils::putContents( $destPath, $this->contents ); |
| 24 |
} |
| 25 |
|
| 26 |
public function getStreamOrString() { |
| 27 |
return $this->contents; |
| 28 |
} |
| 29 |
} |