Habari\Stack::styles PHP Method

styles() public static method

A callback for Stack::get() that outputs styles as link or inline style tags depending on their content
public static styles ( string $element, string $typename = null, string $props = [] ) : string
$element string The style element in the stack
$typename string The media disposition of the content
$props string Additional properties of the style tag output
return string The resulting style or link tag
    public static function styles($element, $typename = null, $props = array())
    {
        $props = $props + array('type' => 'text/css');
        if (!empty($typename)) {
            $props['media'] = $typename;
        }
        $wrapper = '%s';
        if (isset($props['_wrapper'])) {
            $wrapper = $props['_wrapper'];
            unset($props['_wrapper']);
        }
        if (self::is_url($element)) {
            $props = $props + array('rel' => 'stylesheet', 'href' => $element);
            $output = sprintf("<link %s>\r\n", Utils::html_attr($props));
        } else {
            $output = sprintf("<style %2\$s>%1\$s</style>\r\n", $element, Utils::html_attr($props));
        }
        $output = sprintf($wrapper, $output);
        return $output;
    }