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

HomeDomainPayload::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Domain;
6
7
use DarkMatter\Domain\Domain;
8
9
use DarkMatter\Payload\Payload;
10
use DarkMatter\Payload\Status;
11
12
// https://github.com/radarphp/Radar.Adr/blob/2.x/src/Responder/Responder.php
13
14
/**
15
 * Class HomeDomain
16
 *
17
 * This is a very simple domain which is normally used to provide some kind of data for you views.
18
 *
19
 * @package DarkMatterApp\Domains
20
 */
21
class HomeDomainPayload extends Domain
22
{
23
    public function __construct(array $id)
24
    {
25
        $this->id = $id['id'];
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
    }
27
28
    /**
29
     * Retrieves welcome text.
30
     *
31
     * @return string
32
     */
33
    public function getWelcomePayload() : Payload
34
    {
35
        // get the data from the db or filesystem
36
        $payload_dymmy_data = [
37
            'body'  => 'welcome to darkmatter',
38
            'note'  => 'message from: ' . __CLASS__,
39
            'button' => '<a href="http://localhost:8000">index</a>',
40
            'button2' => '<a href="/payloadtest/">payloadtest</a>',
41
            'button3' => '<a href="/payloadtest/43545">payloadtest/43545</a>',
42
            'id' => $this->id
43
        ];
44
45
        // if we get the data or file or whatever, then set the payload STATUS to FOUND
46
        $payload = new Payload(Status::FOUND, $payload_dymmy_data);
47
48
        return $payload;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $payload returns the type DarkMatter\Payload\Payload which is incompatible with the documented return type string.
Loading history...
49
    }
50
}
51