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
|
|
|
|