Completed
Pull Request — master (#200)
by Raffael
16:31
created

AddLocale::start()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2018 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Notification\Migration\Delta;
13
14
use Balloon\Migration\Delta\DeltaInterface;
15
use MongoDB\Database;
16
17
class AddLocale implements DeltaInterface
18
{
19
    /**
20
     * Database.
21
     *
22
     * @var Database
23
     */
24
    protected $db;
25
26
    /**
27
     * Construct.
28
     */
29
    public function __construct(Database $db)
30
    {
31
        $this->db = $db;
32
    }
33
34
    /**
35
     * Start.
36
     */
37
    public function start(): bool
38
    {
39
        $this->db->selectCollection('notification')->updateMany(
40
            ['locale' => ['$exists' => false]],
41
            [
42
                '$set' => ['locale' => 'en_US'],
43
                '$unset' => ['context' => 1],
44
            ]
45
        );
46
47
        return true;
48
    }
49
}
50