Issues (150)

src/Request.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource;
6
7
use OutOfRangeException;
8
use Override;
9
10
use function array_merge;
11
use function in_array;
12
13
/**
14
 * @property $this $lazy
15
 * @property $this $eager
16
 * @psalm-suppress PropertyNotSetInConstructor for DSL
17
 * @psalm-import-type Query from Types
18
 */
19
final class Request extends AbstractRequest
20
{
21
    public const GET = 'get';
22
    public const POST = 'post';
23
    public const PUT = 'put';
24
    public const PATCH = 'patch';
25
    public const DELETE = 'delete';
26
    public const HEAD = 'head';
27
    public const OPTIONS = 'options';
28
29
    /** @psalm-suppress ImplementedReturnTypeMismatch */
30
31
    /** @psalm-suppress PossiblyUnusedReturnValue */
32
    #[Override]
33
    public function __get(string $name): mixed
34
    {
35
        if ($name === 'eager' || $name === 'lazy') {
36
            $this->in = $name;
37
38
            return $this;
39
        }
40
41
        if (in_array($name, ['code', 'headers', 'body'], true)) {
42
            return parent::__get($name);
43
        }
44
45
        throw new OutOfRangeException($name);
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     *
51
     * @param Query $query
0 ignored issues
show
The type BEAR\Resource\Query was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
52
     */
53
    #[Override]
54
    public function withQuery(array $query): RequestInterface
55
    {
56
        $this->query = $query;
57
58
        return $this;
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64
    #[Override]
65
    public function addQuery(array $query): RequestInterface
66
    {
67
        $this->query = array_merge($this->query, $query);
68
69
        return $this;
70
    }
71
72
    /**
73
     * {@inheritDoc}
74
     */
75
    #[Override]
76
    public function toUriWithMethod(): string
77
    {
78
        $uri = $this->toUri();
79
80
        return "{$this->method} {$uri}";
81
    }
82
83
    /**
84
     * {@inheritDoc}
85
     */
86
    #[Override]
87
    public function toUri(): string
88
    {
89
        $this->resourceObject->uri->query = $this->query;
90
91
        return (string) $this->resourceObject->uri;
92
    }
93
94
    /**
95
     * {@inheritDoc}
96
     */
97
    #[Override]
98
    public function linkSelf(string $linkKey): RequestInterface
99
    {
100
        $this->links[] = new LinkType($linkKey, LinkType::SELF_LINK);
101
102
        return $this;
103
    }
104
105
    /**
106
     * {@inheritDoc}
107
     */
108
    #[Override]
109
    public function linkNew(string $linkKey): RequestInterface
110
    {
111
        $this->links[] = new LinkType($linkKey, LinkType::NEW_LINK);
112
113
        return $this;
114
    }
115
116
    /**
117
     * {@inheritDoc}
118
     */
119
    #[Override]
120
    public function linkCrawl(string $linkKey): RequestInterface
121
    {
122
        $this->links[] = new LinkType($linkKey, LinkType::CRAWL_LINK);
123
124
        return $this;
125
    }
126
}
127