BatchRequest::addOperation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
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