Completed
Push — EZP-26835-load-translation-pac... ( f96c61 )
by Nicolas
15:15
created

Collector   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A collect() 0 17 2
1
<?php
2
3
/**
4
 * File containing the Collector class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\Translation;
10
11
/**
12
 * Retrieve all ezplatform translation files installed
13
 */
14
class Collector
15
{
16
    /**
17
     * @var
18
     */
19
    protected $tranlationPattern;
20
21
    /**
22
     * @param string $kernelRootDir
23
     */
24
    public function __construct($kernelRootDir)
25
    {
26
        $this->tranlationPattern = $kernelRootDir . '/../vendor/ezsystems/ezplatform-i18n-*/*/*.xlf';
27
    }
28
29
    /**
30
     * @return array
31
     */
32
    public function collect()
33
    {
34
        $files = glob($this->tranlationPattern);
35
        $meta = [];
36
37
        foreach ($files as $file) {
38
            list($domain, $locale, $format) = explode('.', basename($file), 3);
39
            $meta[] = [
40
                'file'   => $file,
41
                'domain' => $domain,
42
                'locale' => $locale,
43
                'format' => $format
44
            ];
45
        }
46
47
        return $meta;
48
    }
49
}
50