for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of Symplify
* Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
*/
namespace Symplify\PHP7_Sculpin\Renderable\Configuration;
use Symfony\Component\Yaml\Yaml;
use Symplify\PHP7_Sculpin\Renderable\File\File;
final class ConfigurationDecorator
{
public function decorateFile(File $file)
if (preg_match('/^\s*(?:---[\s]*[\r\n]+)(.*?)(?:---[\s]*[\r\n]+)(.*?)$/s', $file->getContent(), $matches)) {
$file->changeContent($matches[2]);
if (!preg_match('/^(\s*[-]+\s*|\s*)$/', $matches[1])) {
$configuration = Yaml::parse($matches[1]);
$file->setConfiguration($configuration);
}