Passed
Push — master ( 18b32f...fa2b73 )
by Jens
08:15
created

GoogleCloudPubSubDestination::fieldDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 4
cts 4
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\Subscription;
6
7
use Commercetools\Core\Model\Common\Context;
8
9
/**
10
 * @package Commercetools\Core\Model\Subscription
11
 *
12
 * @method string getType()
13
 * @method GoogleCloudPubSubDestination setType(string $type = null)
14
 * @method string getProjectId()
15
 * @method GoogleCloudPubSubDestination setProjectId(string $projectId = null)
16
 * @method string getTopic()
17
 * @method GoogleCloudPubSubDestination setTopic(string $topic = null)
18
 */
19
class GoogleCloudPubSubDestination extends Destination
20
{
21 1
    public function fieldDefinitions()
22
    {
23
        return [
24 1
            'type' => [static::TYPE => 'string'],
25 1
            'projectId' => [static::TYPE => 'string'],
26 1
            'topic' => [static::TYPE => 'string'],
27
        ];
28
    }
29
30
    /**
31
     * @param string $projectId
32
     * @param string $topic
33
     * @param Context $context
34
     * @return GoogleCloudPubSubDestination
35
     */
36
    public static function ofProjectIdAndTopic($projectId, $topic, Context $context = null)
37
    {
38
        return static::of($context)->setType(static::DESTINATION_GOOGLE_CLOUD_PUB_SUB)
39
            ->setProjectId($projectId)
40
            ->setTopic($topic);
41
    }
42
}
43