Formatter |
|
---|---|
|
|
This file is part of the Pinocchio library. (c) José Nahuel Cuesta Luengo nahuelcuestaluengo@gmail.com For the full copyright and license information, please view the LICENSE file that was distributed with this source code. |
namespace Pinocchio;
|
Formatter for Pinocchio output files. @author José Nahuel Cuesta Luengo nahuelcuestaluengo@gmail.com |
class Formatter
{
|
Configuration instance. @var |
protected $configuration;
|
Constructor. @param |
public function __construct(Configuration $configuration)
{
$this->configuration = $configuration;
}
|
Format the given Pinocchio instance, optionally making an output
to @param @param @return |
public function format(Pinocchio $pinocchio, $outputFile = null)
{
$annotatedSource = $this->apply($pinocchio);
if (null !== $outputFile) {
file_put_contents($outputFile, $annotatedSource);
}
return $annotatedSource;
}
|
Apply the formatter to the given Pinocchio instance. Returns the resulting HTML page. @param @return |
protected function apply($pinocchio)
{
$variables = array(
'configuration' => $this->configuration,
'pinocchio' => $pinocchio,
);
ob_start();
extract($variables);
include($this->configuration->get('template'));
return ob_get_clean();
}
}
|