RedirectStatuses::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php namespace Arcanedev\LaravelSeo\Entities;
2
3
use Arcanedev\LaravelSeo\Seo;
4
use Symfony\Component\HttpFoundation\Response;
5
6
/**
7
 * Class     RedirectStatuses
8
 *
9
 * @package  Arcanedev\LaravelSeo\Entities
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class RedirectStatuses
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main Methods
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Get the all status codes.
21
     *
22
     * @return \Illuminate\Support\Collection
23
     */
24 10
    public static function keys()
25
    {
26 10
        return collect([
27 10
            Response::HTTP_MOVED_PERMANENTLY,
28 10
            Response::HTTP_SEE_OTHER,
29 10
            Response::HTTP_TEMPORARY_REDIRECT,
30 10
            Response::HTTP_PERMANENTLY_REDIRECT,
31
        ]);
32
    }
33
34
    /**
35
     * Get the all status names.
36
     *
37
     * @param  string|null  $locale
38
     *
39
     * @return \Illuminate\Support\Collection
40
     */
41
    public static function all($locale = null)
42
    {
43 8
        return static::keys()->mapWithKeys(function ($code) use ($locale) {
44 8
            return [$code => Seo::getTrans("redirections.statuses.{$code}", [], $locale)];
45 8
        });
46
    }
47
48
    /**
49
     * Get the status name.
50
     *
51
     * @param  int          $key
52
     * @param  string|null  $default
53
     * @param  string|null  $locale
54
     *
55
     * @return string
56
     */
57 4
    public static function get($key, $default = null, $locale = null)
58
    {
59 4
        return static::all($locale)->get($key, $default);
60
    }
61
}
62