YmlExport   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A export() 0 13 2
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\TranslationsBundle\Service\Export;
13
14
use Symfony\Component\Yaml\Dumper;
15
16
/**
17
 * Class YmlExport for dumping translations to yml file.
18
 */
19
class YmlExport
20
{
21
    /**
22
     * Export translations in to the given file.
23
     *
24
     * @param string $file
25
     * @param array  $translations
26
     *
27
     * @return bool
28
     */
29
    public function export($file, $translations)
30
    {
31
        $bytes = false;
32
33
        if (pathinfo($file, PATHINFO_EXTENSION) === 'yml') {
34
            $ymlDumper = new Dumper();
35
            $ymlContent = '';
36
            $ymlContent .= $ymlDumper->dump($translations, 10);
37
            $bytes = file_put_contents($file, $ymlContent);
38
        }
39
40
        return ($bytes !== false);
41
    }
42
}
43