LaravelSeoMetaBox::addObjectOnPage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Giuga\LaravelSeoMetaBox;
4
5
class LaravelSeoMetaBox
6
{
7
    private array $objectsOnPage = [];
8
9
    public function addObjectOnPage(string $type, int $id): void
10
    {
11
        $this->objectsOnPage[] = [
12
            'type' => $type,
13
            'id' => $id,
14
        ];
15
    }
16
17
    /**
18
     * Retrieve the last object added to the page that can have Seo.
19
     */
20
    public function getObjectOnPage(): ?array
21
    {
22
        if (count($this->objectsOnPage)) {
23
            return end($this->objectsOnPage);
24
        }
25
26
        return null;
27
    }
28
}
29