Completed
Pull Request — 2.x (#27)
by
unknown
02:09
created

PackageFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 0
cbo 1
dl 0
loc 28
ccs 12
cts 12
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A newInstance() 0 14 4
1
<?php
2
/**
3
 *
4
 * This file is part of the Aura Project for PHP.
5
 *
6
 * @package Aura.Intl
7
 *
8
 * @license http://opensource.org/licenses/MIT MIT
9
 *
10
 */
11
namespace Aura\Intl;
12
13
/**
14
 *
15
 * Creates new package instances.
16
 *
17
 * @package Aura.Intl
18
 *
19
 */
20
class PackageFactory
21
{
22
    /**
23
     *
24
     * Returns a new Package instance.
25
     *
26
     * @param array $info An array of package information with keys
27
     * 'formatter', 'fallback', and 'messages'. Typically read from an
28
     * `intl/xx_XX.php` file.
29
     *
30
     * @return Package
31
     *
32
     */
33 1
    public function newInstance(array $info)
34
    {
35 1
        $package = new Package;
36 1
        if (isset($info['fallback'])) {
37 1
            $package->setFallback($info['fallback']);
38 1
        }
39 1
        if (isset($info['formatter'])) {
40 1
            $package->setFormatter($info['formatter']);
41 1
        }
42 1
        if (isset($info['messages'])) {
43 1
            $package->setMessages($info['messages']);
44 1
        }
45 1
        return $package;
46
    }
47
}
48