FeedRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
dl 0
loc 32
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A rules() 0 4 1
A getFeedType() 0 5 2
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