BatchRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperations() 0 3 1
A __construct() 0 3 1
A jsonSerialize() 0 4 1
A addOperation() 0 4 1
A removeOperation() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlexCk\MailchimpBundle\Model\MailChimp;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
10
class BatchRequest implements \JsonSerializable
11
{
12
    /**
13
     * @var ArrayCollection
14
     */
15
    private $operations;
16
17
    /**
18
     * BatchRequest constructor.
19
     */
20
    public function __construct()
21
    {
22
        $this->operations = new ArrayCollection();
23
    }
24
25
    public function jsonSerialize()
26
    {
27
        return [
28
            'operations' => $this->getOperations()->getValues()
29
        ];
30
    }
31
32
    public function getOperations(): Collection
33
    {
34
        return $this->operations;
35
    }
36
37
    public function addOperation(BatchOperation $operation): BatchRequest
38
    {
39
        $this->operations->add($operation);
40
        return $this;
41
    }
42
43
    public function removeOperation(BatchOperation $operation): BatchRequest
44
    {
45
        $this->operations->removeElement($operation);
46
        return $this;
47
    }
48
}
49