Completed
Branch dev (bc6e47)
by Raffael
02:23
created

JsonEncodeFilteredCollection::getCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Balloon
7
 *
8
 * @author      Raffael Sahli <[email protected]>
9
 * @copyright   Copryright (c) 2012-2017 gyselroth GmbH (https://gyselroth.com)
10
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
11
 */
12
13
namespace Balloon\Database\Delta;
14
15 View Code Duplication
class JsonEncodeFilteredCollection extends AbstractDelta
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * Get collection.
19
     *
20
     * @return string
21
     */
22
    public function getCollection(): string
23
    {
24
        return 'storage';
25
    }
26
27
    /**
28
     * Upgrade object.
29
     *
30
     * @return array
31
     */
32
    public function upgradeObject(array $object): array
33
    {
34
        if (true === $object['directory']) {
35
            return [];
36
        }
37
38
        if (isset($object['file'])) {
39
            $file = $object['file'];
40
        } else {
41
            $file = null;
42
        }
43
44
        return [
45
            '$unset' => ['file' => 1],
46
            '$set' => [
47
                'storage' => [
48
                    'adapter' => 'gridfs',
49
                    'attributes' => $file,
50
                ],
51
            ],
52
        ];
53
    }
54
}
55