Completed
Push — master ( 7fe5eb...9bad48 )
by Beñat
08:54 queued 04:27
created

ViewUserNotifications   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 16 1
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\Notifier\Application\Inbox\Notification;
16
17
use Kreta\Notifier\Domain\ReadModel\Inbox\Notification\NotificationSpecificationFactory;
18
use Kreta\Notifier\Domain\ReadModel\Inbox\Notification\NotificationView;
19
20
class ViewUserNotifications
21
{
22
    private $view;
23
    private $specificationFactory;
24
25
    public function __construct(NotificationView $view, NotificationSpecificationFactory $specificationFactory)
26
    {
27
        $this->view = $view;
28
        $this->specificationFactory = $specificationFactory;
29
    }
30
31
    public function __invoke(ViewUserNotificationsQuery $query) : array
32
    {
33
        $userId = $query->userId();
34
        $from = $query->offset();
35
        $size = $query->limit();
36
        $status = $query->status();
37
38
        return $this->view->search(
39
            $this->specificationFactory->createNotificationsOfUser(
40
                $userId,
41
                $from,
42
                $size,
43
                $status
44
            )
45
        );
46
    }
47
}
48