Completed
Branch dev (276354)
by Raffael
15:43
created

UserCreateDate   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A start() 0 11 1
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\Migration\Delta;
13
14
use MongoDB\BSON\UTCDateTime;
15
use MongoDB\Database;
16
17
class UserCreateDate implements DeltaInterface
18
{
19
    /**
20
     * Database.
21
     *
22
     * @var Database
23
     */
24
    protected $db;
25
26
    /**
27
     * Construct.
28
     *
29
     * @param Database $db
30
     */
31
    public function __construct(Database $db)
32
    {
33
        $this->db = $db;
34
    }
35
36
    /**
37
     * Start.
38
     *
39
     * @return bool
40
     */
41
    public function start(): bool
42
    {
43
        $cursor = $this->db->user->updateMany([
0 ignored issues
show
Unused Code introduced by
$cursor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
44
            'created' => ['$exists' => false],
45
        ], [
46
            'created' => new UTCDateTime(),
47
            'changed' => new UTCDateTime(),
48
        ]);
49
50
        return true;
51
    }
52
}
53