<?php

namespace Velis\Mvc\View\Helper;

/**
 * Javascript file helper
 * @author Michał Nosek <michal.nosek@velis.pl
 */
class Script
{
    /**
     * Already loaded scripts
     * @var array
     */
    public $_loadedScripts = array();


    /**
     * Returns script include HTML
     * @return string
     */
    public function __invoke($url)
    {
        if (!in_array($url, $this->_loadedScripts)) {
            $this->_loadedScripts[] = $url;
            $html = '<script type="text/javascript" src="' . $url . '"></script>';
        }
        return $html;
    }
}
