AbstractContentfulSyncService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 70
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
handleEntryPublished() 0 1 ?
handleEntryDeleted() 0 1 ?
handleAssetPublished() 0 1 ?
handleAssetDeleted() 0 1 ?
A __construct() 0 4 1
A publishEntry() 0 4 1
A deleteEntry() 0 4 1
A publishAsset() 0 4 1
A deleteAsset() 0 4 1
1
<?php
2
3
namespace Digia\Lumen\ContentfulSync\Services;
4
5
use Digia\Lumen\ContentfulSync\Contracts\ContentfulSyncServiceContract;
6
use Digia\Lumen\ContentfulSync\Jobs\ContentfulDeleteAssetJob;
7
use Digia\Lumen\ContentfulSync\Jobs\ContentfulDeleteEntryJob;
8
use Digia\Lumen\ContentfulSync\Jobs\ContentfulPublishAssetJob;
9
use Digia\Lumen\ContentfulSync\Jobs\ContentfulPublishEntryJob;
10
use Illuminate\Contracts\Queue\Queue;
11
12
/**
13
 * Class ContentfulSyncServiceContract
14
 * @package Digia\Lumen\ContentfulSync\Services
15
 */
16
abstract class AbstractContentfulSyncService implements ContentfulSyncServiceContract
17
{
18
19
    /**
20
     * @var Queue
21
     */
22
    private $queue;
23
24
    /**
25
     * @inheritdoc
26
     */
27
    abstract public function handleEntryPublished(string $contentType, string $entryJson, bool $ignoreExisting);
28
29
    /**
30
     * @inheritdoc
31
     */
32
    abstract public function handleEntryDeleted(string $contentType, string $entryId);
33
34
    /**
35
     * @inheritdoc
36
     */
37
    abstract public function handleAssetPublished(string $assetJson, bool $ignoreExisting);
38
39
    /**
40
     * @inheritdoc
41
     */
42
    abstract public function handleAssetDeleted(string $assetId);
43
44
    /**
45
     * ContentfulSyncService constructor.
46
     *
47
     * @param Queue $queue
48
     */
49
    public function __construct(Queue $queue)
50
    {
51
        $this->queue = $queue;
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public function publishEntry(string $contentType, string $entryJson, bool $ignoreExisting = false): void
58
    {
59
        $this->queue->push(new ContentfulPublishEntryJob($contentType, $entryJson, $ignoreExisting));
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    public function deleteEntry(string $contentType, string $entryId): void
66
    {
67
        $this->queue->push(new ContentfulDeleteEntryJob($contentType, $entryId));
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73
    public function publishAsset(string $assetJson, bool $ignoreExisting = false): void
74
    {
75
        $this->queue->push(new ContentfulPublishAssetJob($assetJson, $ignoreExisting));
76
    }
77
78
    /**
79
     * @inheritdoc
80
     */
81
    public function deleteAsset(string $assetId): void
82
    {
83
        $this->queue->push(new ContentfulDeleteAssetJob($assetId));
84
    }
85
}
86