Passed
Pull Request — develop (#492)
by nikos
11:03 queued 10s
created

StoreDraft::fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 */
4
5
namespace Commercetools\Core\Model\Store;
6
7
use Commercetools\Core\Model\Common\Context;
8
use Commercetools\Core\Model\Common\JsonObject;
9
use Commercetools\Core\Model\Common\LocalizedString;
10
11
/**
12
 * @package Commercetools\Core\Model\Store
13
 * @link https://docs.commercetools.com/http-api-projects-stores#storedraft
14
 *
15
 * @method string getKey()
16
 * @method StoreDraft setKey(string $key = null)
17
 * @method LocalizedString getName()
18
 * @method StoreDraft setName(LocalizedString $name = null)
19
 */
20
class StoreDraft extends JsonObject
21
{
22 20
    public function fieldDefinitions()
23
    {
24
        return [
25 20
            'key' => [static::TYPE => 'string'],
26 20
            'name' => [static::TYPE => LocalizedString::class],
27
        ];
28
    }
29
30
    /**
31
     * @param string $key
32
     * @param Context|callable $context
33
     * @return StoreDraft
34
     */
35
    public static function ofKey($key, Context $context)
36
    {
37
        return static::of($context)->setKey($key);
38
    }
39
40
    /**
41
     * @param string $key
42
     * @param LocalizedString $name
43
     * @param Context|null $context
44
     * @return StoreDraft
45
     */
46 18
    public static function ofKeyAndName($key, LocalizedString $name, $context = null)
47
    {
48 18
        return static::of($context)->setKey($key)->setName($name);
49
    }
50
}
51