API::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * Anime List Client
4
 *
5
 * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
6
 *
7
 * PHP version 7
8
 *
9
 * @package     AnimeListClient
10
 * @author      Timothy J. Warren <[email protected]>
11
 * @copyright   2015 - 2017  Timothy J. Warren
12
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @version     4.0
14
 * @link        https://github.com/timw4mail/HummingBirdAnimeClient
15
 */
16
17
namespace Aviat\AnimeClient\Model;
18
19
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
20
use Aviat\Ion\Model;
21
22
/**
23
 * Base model for api interaction
24
 */
25
class API extends Model {
26
27
	use ContainerAware;
28
29
	/**
30
	 * Config manager
31
	 * @var ConfigInterface
32
	 */
33
	protected $config;
34
35
	/**
36
	 * Cache manager
37
	 * @var \Psr\Cache\CacheItemPoolInterface
38
	 */
39
	protected $cache;
40
41
	/**
42
	 * Constructor
43
	 *
44
	 * @param ContainerInterface $container
0 ignored issues
show
Documentation introduced by
Should the type for parameter $container not be \Aviat\Ion\Di\ContainerInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
45
	 */
46
	public function __construct(ContainerInterface $container)
47
	{
48
		$this->container = $container;
49
		$this->config = $container->get('config');
50
	}
51
52
	/**
53
	 * Sort the list entries by their title
54
	 *
55
	 * @codeCoverageIgnore
56
	 * @param array $array
57
	 * @param string $sort_key
58
	 * @return void
59
	 */
60
	protected function sortByName(array &$array, string $sort_key)
61
	{
62
		$sort = [];
63
64
		foreach ($array as $key => $item)
65
		{
66
			$sort[$key] = $item[$sort_key]['titles'][0];
67
		}
68
69
		array_multisort($sort, SORT_ASC, $array);
70
	}
71
}