Completed
Push — develop ( f876c4...3b7fce )
by
unknown
10:26
created

ResourceIdentifier::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @ct-jensschulze <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\Common;
7
8
/**
9
 * @package Commercetools\Core\Model\Common
10
 *
11
 * @method string getTypeId()
12
 * @method ResourceIdentifier setTypeId(string $typeId = null)
13
 * @method string getId()
14
 * @method ResourceIdentifier setId(string $id = null)
15
 * @method string getKey()
16
 * @method ResourceIdentifier setKey(string $key = null)
17
 */
18
abstract class ResourceIdentifier extends JsonObject
19
{
20
    const TYPE_ID = 'typeId';
21
    const ID = 'id';
22
    const KEY = 'key';
23
24 65 View Code Duplication
    public function fieldDefinitions()
0 ignored issues
show
Duplication introduced by
This method 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...
25
    {
26
        return [
27 65
            static::TYPE_ID => [self::TYPE => 'string'],
28 65
            static::ID => [self::TYPE => 'string'],
29 65
            static::KEY => [self::TYPE => 'string']
30 65
        ];
31
    }
32
33
    /**
34
     * @param $type
35
     * @param $id
36
     * @param Context|callable $context
37
     * @return Reference
38
     */
39 70
    public static function ofTypeAndId($type, $id, $context = null)
40
    {
41 70
        $reference = static::of($context);
42 70
        return $reference->setTypeId($type)->setId($id);
43
    }
44
45
    /**
46
     * @param $type
47
     * @param $key
48
     * @param Context|callable $context
49
     * @return Reference
50
     */
51
    public static function ofTypeAndKey($type, $key, $context = null)
52
    {
53
        $reference = static::of($context);
54
        return $reference->setTypeId($type)->setKey($key);
55
    }
56
57 3
    public function jsonSerialize()
58
    {
59 3
        $data = parent::jsonSerialize();
60 3
        unset($data['obj']);
61
62 3
        return $data;
63
    }
64
}
65