for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @description Insert the contents of a file into selected element.
* @author Chris Johnson <[email protected]>
* @copyright 2020 Chris Johnson <[email protected]>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version 1.0
*/
namespace Transphporm\TSSFunction;
class File implements \Transphporm\TSSFunction
{
private $filePath;
public function __construct(\Transphporm\FilePath $filePath)
$this->filePath = $filePath;
}
* @param array $args
* @param \DomElement|null $element
*
* @return array
* @throws \Exception
public function run(array $args, \DomElement $element = null)
$fileContents = $args[0];
$path = $this->filePath->getFilePath($fileContents);
if (!file_exists($path)) {
throw new \Exception('File does not exist at: ' . $path);
$fileContents = file_get_contents($path);
return $fileContents;