Passed
Branch main (0a6531)
by Zsolt
18:15 queued 08:15
created

HomeAction::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Action;
6
7
use DarkMatter\Action\HtmlAction;
8
use DarkMatter\Http\Response;
9
use App\Domain\HomeDomain;
10
11
/**
12
 * Class HomeAction
13
 *
14
 * This is an example of a HtmlAction. In every HtmlAction you have access to the HtmlResponder.
15
 *
16
 * @package App\Actions
17
 */
18
class HomeAction extends HtmlAction
19
{
20
    /**
21
     * Every Action needs to have a "__invoke" methods which is automatically executed by the application.
22
     * This methods needs to return the response which will than be send to the client.
23
     *
24
     * @param array $arguments Possible arguments from the URL.
25
     * @return Response
26
     */
27
    public function __invoke(array $arguments = []): Response
28
    {
29
        // Fetch some data from a domain:
30
        $domain = new HomeDomain;
31
        $data = [
32
            'body' => $domain->getWelcomeText(),
33
        ];
34
35
        return $this->responder->found($data);
36
    }
37
}
38