tapestry-cloud/tapestry

View on GitHub
src/Plates/Extensions/Url.php

Summary

Maintainability
A
0 mins
Test Coverage
C
75%
<?php

namespace Tapestry\Plates\Extensions;

use League\Plates\Engine;
use League\Plates\Extension\ExtensionInterface;

class Url implements ExtensionInterface
{
    /**
     * @var \Tapestry\Entities\Url
     */
    private $url;

    /**
     * Url constructor.
     *
     * @param \Tapestry\Entities\Url $url
     */
    public function __construct(\Tapestry\Entities\Url $url)
    {
        $this->url = $url;
    }

    public function register(Engine $engine)
    {
        $engine->registerFunction('url', [$this, 'url']);
    }

    public function url($uri = '')
    {
        return $this->url->parse($uri);
    }
}