FeedRequest::getFeedType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace WebDevEtc\BlogEtc\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Validation\Rule;
7
8
class FeedRequest extends FormRequest
9
{
10
    /**
11
     * Always return true, as this is just to view the rss feed.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * @return array
22
     */
23
    public function rules(): array
24
    {
25
        return [
26
            'type' => [Rule::in(['rss', 'atom'])],
27
        ];
28
    }
29
30
    /**
31
     * Is this request for an RSS feed or Atom feed? defaults to atom.
32
     *
33
     * @return string
34
     */
35
    public function getFeedType(): string
36
    {
37
        return 'rss' === $this->get('type')
38
            ? 'rss'
39
            : 'atom';
40
    }
41
}
42