Completed
Push — develop ( b6cb2c...9ca58c )
by Jens
15:17 queued 07:08
created

ExtensionDraft   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldDefinitions() 0 6 1
A ofDestinationAndTriggers() 0 6 1
1
<?php
2
/**
3
 */
4
5
namespace Commercetools\Core\Model\Extension;
6
7
use Commercetools\Core\Model\Common\Context;
8
use Commercetools\Core\Model\Common\JsonObject;
9
10
/**
11
 * @package Commercetools\Core\Model\Extension
12
 * @link https://docs.commercetools.com/http-api-projects-api-extensions.html#extensiondraft
13
 * @method string getKey()
14
 * @method ExtensionDraft setKey(string $key = null)
15
 * @method Destination getDestination()
16
 * @method ExtensionDraft setDestination(Destination $destination = null)
17
 * @method TriggerCollection getTriggers()
18
 * @method ExtensionDraft setTriggers(TriggerCollection $triggers = null)
19
 */
20
class ExtensionDraft extends JsonObject
21
{
22 5
    public function fieldDefinitions()
23
    {
24
        return [
25 5
            'key' => [static::TYPE => 'string'],
26 5
            'destination' => [static::TYPE => Destination::class],
27 5
            'triggers' => [static::TYPE => TriggerCollection::class],
28
        ];
29
    }
30
31
    /**
32
     * @param Destination $destination
33
     * @param TriggerCollection $triggers
34
     * @param Context|callable $context
35
     * @return ExtensionDraft
36
     */
37 4
    public static function ofDestinationAndTriggers(
38
        Destination $destination,
39
        TriggerCollection $triggers,
40
        $context = null
41
    ) {
42 4
        return static::of($context)->setDestination($destination)->setTriggers($triggers);
43
    }
44
}
45