Completed
Push — develop ( 991012...b60d88 )
by Jens
08:17
created

CustomFieldObjectDraft::fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 */
5
6
namespace Commercetools\Core\Model\CustomField;
7
8
use Commercetools\Core\Model\Common\Context;
9
use Commercetools\Core\Model\Common\JsonObject;
10
use Commercetools\Core\Model\Type\TypeReference;
11
use Commercetools\Core\Model\Common\ResourceIdentifier;
12
13
/**
14
 * @package Commercetools\Core\Model\CustomField
15
 * @link https://dev.commercetools.com/http-api-projects-custom-fields.html#new-custom-fields
16
 * @method FieldContainer getFields()
17
 * @method CustomFieldObjectDraft setFields(FieldContainer $fields = null)
18
 * @method TypeReference getType()
19
 * @method CustomFieldObjectDraft setType(TypeReference $type = null)
20
 */
21
class CustomFieldObjectDraft extends JsonObject
22
{
23 4 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...
24
    {
25
        return [
26 4
            'type' => [static::TYPE => '\Commercetools\Core\Model\Type\TypeReference'],
27 4
            'fields' => [static::TYPE => '\Commercetools\Core\Model\CustomField\FieldContainer']
28
        ];
29
    }
30
31
    /**
32
     * @param $typeKey
33
     * @param Context|callable $context
34
     * @return CustomFieldObjectDraft
35
     */
36
    public static function ofTypeKey($typeKey, $context = null)
37
    {
38
        $draft = static::of($context)->setType(TypeReference::ofKey($typeKey));
39
40
        return $draft;
41
    }
42
43
    /**
44
     * @param string $typeId
45
     * @param Context|callable $context
46
     * @return CustomFieldObjectDraft
47
     */
48
    public static function ofTypeId($typeId, $context = null)
49
    {
50
        $draft = static::of($context)->setType(TypeReference::ofId($typeId));
51
52
        return $draft;
53
    }
54
55
    /**
56
     * @param TypeReference $type
57
     * @param Context|callable $context
58
     * @return CustomFieldObjectDraft
59
     */
60 4
    public static function ofType(TypeReference $type, $context = null)
61
    {
62 4
        $draft = static::of($context)->setType($type);
63
64 4
        return $draft;
65
    }
66
}
67