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

CurrencyLoader::curriencies()   A

Complexity

Conditions 6
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
nc 4
nop 1
dl 0
loc 17
rs 9.0777
c 0
b 0
f 0
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