Passed
Push — master ( 20ba69...1ea7e6 )
by Victor
47s queued 11s
created

ItemPresenter::present()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Tests\Integration\ErrorSuppression\Presenters;
5
6
use Psr\Http\Message\ServerRequestInterface;
7
use RuntimeException;
8
use Shoot\Shoot\PresentationModel;
9
use Shoot\Shoot\PresenterInterface;
10
11
final class ItemPresenter implements PresenterInterface
12
{
13
    /**
14
     * Receives the current HTTP request context and the presentation model assigned to the view. If necessary,
15
     * populates the presentation model with data and returns it.
16
     *
17
     * @param ServerRequestInterface $request
18
     * @param PresentationModel      $presentationModel
19
     *
20
     * @return PresentationModel
21
     */
22
    public function present(ServerRequestInterface $request, PresentationModel $presentationModel): PresentationModel
23
    {
24
        if ($request->getAttribute('throw_logic_exception', 'n') === 'y') {
25
            return $presentationModel->withVariables([
26
                'throw_logic_exception' => true,
27
            ]);
28
        }
29
30
        throw new RuntimeException('item_exception');
31
    }
32
}
33