Archived
1
0
Fork 0
This repository has been archived on 2026-04-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
httpcb/app/library/ViewHelper/Icon.php
2023-04-30 16:57:42 +02:00

50 lines
1,007 B
PHP

<?php
namespace Httpcb\ViewHelper;
/**
* Class Icon
*
* @package ViewHelper
*/
class Icon extends AbstractHelper
{
protected $_prefix = [
'brand' => 'fab',
'regular' => 'far',
'solid' => 'fas'
];
public function icon($name, $args = array())
{
list($prefix, $name) = $this->_parseName($name);
$classes = array(
'icon',
$prefix,
'fa-' . $name
);
if (is_array($args)) {
foreach ($args as $arg) {
$classes[] .= 'fa-' . $arg;
}
}
$classes = implode(' ', $classes);
return '<i class="' . $classes . '"></i>';
}
protected function _parseName($name)
{
$parts = explode('/', $name);
if (count($parts) > 1) {
$prefix = $parts[0];
$name = $parts[1];
} else {
$prefix = 'regular';
}
return array($this->_prefix[$prefix], $name);
}
}