Completed
Push — master ( f1f91d...70afdc )
by ARCANEDEV
04:46
created

PostStatus::all()   A

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
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php namespace Arcanesoft\Blog\Entities;
2
3
use Arcanedev\Support\Collection;
4
5
/**
6
 * Class     PostStatus
7
 *
8
 * @package  Arcanesoft\Blog\Entities
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class PostStatus
12
{
13
    /* -----------------------------------------------------------------
14
     |  Constants
15
     | -----------------------------------------------------------------
16
     */
17
18
    const STATUS_DRAFT     = 'draft';
19
    const STATUS_PUBLISHED = 'published';
20
21
    /* -----------------------------------------------------------------
22
     |  Main Methods
23
     | -----------------------------------------------------------------
24
     */
25
26
    /**
27
     * Get all posts status keys.
28
     *
29
     * @return \Illuminate\Support\Collection
30
     */
31 33
    public static function keys()
32
    {
33 33
        return new Collection([
34 33
            static::STATUS_DRAFT,
35 33
            static::STATUS_PUBLISHED,
36 11
        ]);
37
    }
38
39
    /**
40
     * Get all posts status
41
     *
42
     * @param  string|null  $locale
43
     *
44
     * @return \Illuminate\Support\Collection
45
     */
46
    public static function all($locale = null)
47
    {
48 30
        return static::keys()->mapWithKeys(function ($key) use ($locale) {
49 30
            return [$key => trans("blog::posts.statuses.{$key}", [], $locale)];
50 30
        });
51
    }
52
53
    /**
54
     * Get a post status.
55
     *
56
     * @param  string       $key
57
     * @param  mixed        $default
58
     * @param  string|null  $locale
59
     *
60
     * @return string|null
61
     */
62 24
    public static function get($key, $default = null, $locale = null)
63
    {
64 24
        return self::all($locale)->get($key, $default);
65
    }
66
}
67