for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Digia\GraphQL\Language;
use Digia\GraphQL\Error\InvariantException;
/**
* Class MultiFileSourceBuilder
* @package Digia\GraphQL\Language
*/
class MultiFileSourceBuilder implements SourceBuilderInterface
{
* @var string[]
private $filePaths;
* MultiFileSourceBuilder constructor.
* @param string[] $directoryPaths
public function __construct(array $directoryPaths)
$this->filePaths = $directoryPaths;
}
* @inheritdoc
*
* @throws InvariantException
public function buildSource(): Source
$combinedSource = '';
foreach ($this->filePaths as $filePath) {
if (!\file_exists($filePath) || !\is_readable($filePath)) {
throw new InvariantException(sprintf('The file %s cannot be found or is not readable', $filePath));
$combinedSource .= \file_get_contents($filePath);
return new Source($combinedSource);