PostStatus   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 56
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 6 1
A get() 0 4 1
A keys() 0 7 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 42
    public static function keys()
32
    {
33 42
        return new Collection([
0 ignored issues
show
Deprecated Code introduced by
The class Arcanedev\Support\Collection has been deprecated with message: Use the basic laravel collection

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
34 42
            static::STATUS_DRAFT,
35 42
            static::STATUS_PUBLISHED,
36
        ]);
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 39
        return static::keys()->mapWithKeys(function ($key) use ($locale) {
49 39
            return [$key => trans("blog::posts.statuses.{$key}", [], $locale)];
50 39
        });
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 27
    public static function get($key, $default = null, $locale = null)
63
    {
64 27
        return self::all($locale)->get($key, $default);
65
    }
66
}
67