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

NoteParser::hasNoteObsolete()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 12
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