CommentGetAccessProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Leonidas\Library\System\Model\Comment;
4
5
use Leonidas\Contracts\System\Model\Comment\CommentInterface;
6
use Leonidas\Contracts\System\Model\GetAccessProviderInterface;
7
use Leonidas\Contracts\System\Schema\Comment\CommentEntityManagerInterface;
8
use Leonidas\Library\System\Model\GetAccessProvider;
9
10
class CommentGetAccessProvider extends GetAccessProvider implements GetAccessProviderInterface
11
{
12
    public function __construct(CommentInterface $comment)
13
    {
14
        parent::__construct($comment, $this->resolvedGetters($comment));
15
    }
16
17
    protected function resolvedGetters(CommentInterface $comment): array
18
    {
19
        $dateFormat = CommentEntityManagerInterface::DATE_FORMAT;
20
21
        $getDate = fn () => $comment->getDate()->format($dateFormat);
22
        $getDateGmt = fn () => $comment->getDateGmt()->format($dateFormat);
23
24
        return [
25
            'date' => $getDate,
26
            'dateGmt' => $getDateGmt,
27
            'date_gmt' => $getDateGmt,
28
        ];
29
    }
30
}
31