1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Templating;
13
14/**
15 * TemplateNameParser is the default implementation of TemplateNameParserInterface.
16 *
17 * This implementation takes everything as the template name
18 * and the extension for the engine.
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 */
22class TemplateNameParser implements TemplateNameParserInterface
23{
24    /**
25     * {@inheritdoc}
26     */
27    public function parse($name)
28    {
29        if ($name instanceof TemplateReferenceInterface) {
30            return $name;
31        }
32
33        $engine = null;
34        if (false !== $pos = strrpos($name, '.')) {
35            $engine = substr($name, $pos + 1);
36        }
37
38        return new TemplateReference($name, $engine);
39    }
40}
41