Completed
Push — master ( 13f2dd...a39436 )
by Tobias
05:16
created

NoteParser   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 52
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getNotes() 0 10 2
A hasNoteObsolete() 0 10 3
A hasNoteNew() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[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 Translation\Bundle\Catalogue;
13
14
use Symfony\Component\Translation\MetadataAwareInterface;
15
16
class NoteParser
17
{
18
    /**
19
     * @param $domain
20
     * @param $key
21
     * @param MetadataAwareInterface $catalogue
22
     *
23
     * @return array
24
     */
25
    public function getNotes($domain, $key, MetadataAwareInterface $catalogue)
26
    {
27
        $meta = $catalogue->getMetadata($key, $domain);
28
29
        if (!isset($meta['notes'])) {
30
            return [];
31
        }
32
33
        return $meta['notes'];
34
    }
35
36
    /**
37
     * @param array $notes
38
     *
39
     * @return bool
40
     */
41
    public function hasNoteObsolete(array $notes)
42
    {
43
        foreach ($notes as $note) {
44
            if ($note['content'] === 'status:obsolete') {
45
                return true;
46
            }
47
        }
48
49
        return false;
50
    }
51
52
    /**
53
     * @param array $notes
54
     *
55
     * @return bool
56
     */
57
    public function hasNoteNew(array $notes)
58
    {
59
        foreach ($notes as $note) {
60
            if ($note['content'] === 'status:new') {
61
                return true;
62
            }
63
        }
64
65
        return false;
66
    }
67
}
68