Completed
Push — master ( 0842cd...0b5524 )
by ARCANEDEV
07:12
created

SitemapFrequency   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A keys() 0 6 1
A all() 0 6 1
A get() 0 4 1
A exists() 0 4 1
1
<?php namespace Arcanedev\LaravelSitemap\Entities;
2
3
use Arcanedev\LaravelSitemap\Contracts\SitemapFrequency as SitemapFrequencyContract;
4
5
/**
6
 * Class     SitemapFrequency
7
 *
8
 * @package  Arcanedev\LaravelSitemap\Entities
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class SitemapFrequency implements SitemapFrequencyContract
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Main Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Get all the valid frequency keys.
19
     *
20
     * @return array
21
     */
22 24
    public static function keys()
23
    {
24
        return [
25 24
            self::ALWAYS, self::HOURLY, self::DAILY, self::WEEKLY, self::MONTHLY, self::YEARLY, self::NEVER
26 18
        ];
27
    }
28
29
    /**
30
     * Get all the valid frequency values.
31
     *
32
     * @param  string|null  $locale
33
     *
34
     * @return array
35
     */
36
    public static function all($locale = null)
37
    {
38 8
        return array_map(function ($key) use ($locale) {
39 8
            return self::get($key, $locale);
40 8
        }, array_combine(self::keys(), self::keys()));
41
    }
42
43
    /**
44
     * Get the translated frequency name.
45
     *
46
     * @param  string       $key
47
     * @param  string|null  $locale
48
     *
49
     * @return string
50
     */
51 8
    public static function get($key, $locale = null)
52
    {
53 8
        return trans("sitemap::frequencies.$key", [], 'messages', $locale);
54
    }
55
56
    /**
57
     * Check if the frequency is valid value.
58
     *
59
     * @param  string  $key
60
     *
61
     * @return bool
62
     */
63 8
    public static function exists($key)
64
    {
65 8
        return in_array($key, self::keys());
66
    }
67
}
68