LaravelSeoMetaBox::getObjectOnPage()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 7
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