Test Failed
Push — develop ( 6f35c3...80aa86 )
by Jens
09:29
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 0
Metric Value
dl 7
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
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#customfieldsdraft
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 CustomFieldObject
22
{
23
    /**
24
     * @param $typeKey
25
     * @param Context|callable $context
26
     * @return CustomFieldObjectDraft
27
     */
28 8
    public static function ofTypeKey($typeKey, $context = null)
29
    {
30 8
        $draft = static::of($context)->setType(TypeReference::ofKey($typeKey));
31
32 8
        return $draft;
33
    }
34
35
    /**
36
     * @param string $typeId
37
     * @param Context|callable $context
38
     * @return CustomFieldObjectDraft
39
     */
40
    public static function ofTypeId($typeId, $context = null)
41
    {
42
        $draft = static::of($context)->setType(TypeReference::ofId($typeId));
43
44
        return $draft;
45
    }
46
47
    /**
48
     * @param TypeReference $type
49
     * @param Context|callable $context
50
     * @return CustomFieldObjectDraft
51
     */
52 4
    public static function ofType(TypeReference $type, $context = null)
53
    {
54 4
        $draft = static::of($context)->setType($type);
55
56 4
        return $draft;
57
    }
58
}
59