Completed
Push — develop ( a41b6c...a89f5d )
by Abdelrahman
01:06
created

CurrencyLoader   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A curriencies() 0 17 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Country;
6
7
use Rinvex\Country\CountryLoader;
8
9
class CurrencyLoader
10
{
11
    protected static $curriencies = [];
12
13
    /**
14
     * Retrive all the curriencies of all countries
15
     * @param  boolean $longlist states if need all the details of the curriencies or only the keys
16
     * @return array
17
     */
18
    public static function curriencies($longlist = false): array
19
    {
20
        $list = $longlist ? 'longlist' : 'shortlist';
21
22
        if(!isset(static::$curriencies[$list])) {
23
            
24
            $countries = CountryLoader::countries(true);
25
26
            foreach ($countries as $country) {
27
                foreach ($country["currency"] as $currency => $details) {
28
                    static::$curriencies[$list][$currency] = $longlist? $details: $currency; 
29
                }
30
            }
31
        } 
32
33
        return static::$curriencies[$list];
34
    }
35
}
36