Passed
Push — develop ( 858b20...043195 )
by Daniel
23:31
created

picker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A picker() 0 27 3
1
<?php
2
3
/**
4
 *
5
 * @package sitemaker
6
 * @copyright (c) 2013 Daniel A. (blitze)
7
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
 *
9
 */
10
11
namespace blitze\sitemaker\services\icons;
12
13
use Symfony\Component\Yaml\Yaml;
14
15
/**
16
 * Sitemaker icons
17
 */
18
class picker
19
{
20
	/** @var \phpbb\language\language */
21
	protected $translator;
22
23
	/** @var \blitze\sitemaker\services\util */
24
	protected $util;
25
26
	/** @var \blitze\sitemaker\services\template */
27
	protected $ptemplate;
28
29
	/** @var string */
30
	protected $icon_categories_yml;
31
32
	/**
33
	 * Constructor
34
	 *
35
	 * @param \phpbb\language\language     			$translator     		Language object
36
	 * @param \blitze\sitemaker\services\util		$util					Sitemaker utility object
37
	 * @param \blitze\sitemaker\services\template	$ptemplate				Sitemaker Template object
38
	 * @param string								$icon_categories_yml	YAML file containing fontawesome icon categories
39
	 */
40
	public function __construct(\phpbb\language\language $translator, \blitze\sitemaker\services\util $util, \blitze\sitemaker\services\template $ptemplate, $icon_categories_yml)
41
	{
42
		$this->translator          = $translator;
43
		$this->util                = $util;
44
		$this->ptemplate           = $ptemplate;
45
		$this->icon_categories_yml = $icon_categories_yml;
46
	}
47
48
	/**
49
	 * Load icon picker
50
	 */
51
	public function picker()
52
	{
53
		$this->translator->add_lang('icons', 'blitze/sitemaker');
54
		$this->ptemplate->set_style(array('ext/blitze/sitemaker/styles', 'styles'));
55
56
		$this->util->add_assets(array(
57
			'css'	=> array_filter(array(
58
				defined('IN_ADMIN') ? $this->util->get_web_path() . 'assets/css/font-awesome.min.css' : '',
59
			))
60
		));
61
62
		$icons_tpl = 'fontawesome4';
63
		if (phpbb_version_compare(PHPBB_VERSION, '3.3.1', '>='))
64
		{
65
			$icons_tpl = 'fontawesome5';
66
			$categories = Yaml::parseFile($this->icon_categories_yml);
0 ignored issues
show
Bug introduced by
The method parseFile() does not exist on Symfony\Component\Yaml\Yaml. Did you maybe mean parse()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

66
			/** @scrutinizer ignore-call */ 
67
   $categories = Yaml::parseFile($this->icon_categories_yml);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
68
			$this->ptemplate->assign_var('categories', $categories);
69
		}
70
71
		$this->ptemplate->assign_var('icons_tpl', $icons_tpl);
72
73
		$this->ptemplate->set_filenames(array(
74
			'icons'	=> 'icons/picker.html'
75
		));
76
77
		return $this->ptemplate->assign_display('icons');
78
	}
79
}
80