1
|
|
|
<?php namespace Arcanedev\LaravelSitemap\Entities; |
2
|
|
|
|
3
|
|
|
use Arcanedev\LaravelSitemap\Contracts\Entities\ChangeFrequency as ChangeFrequencyContract; |
4
|
|
|
use Illuminate\Support\Collection; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class ChangeFrequency |
8
|
|
|
* |
9
|
|
|
* @package Arcanedev\LaravelSitemap\Entities |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class ChangeFrequency implements ChangeFrequencyContract |
13
|
|
|
{ |
14
|
|
|
/* ----------------------------------------------------------------- |
15
|
|
|
| Main Methods |
16
|
|
|
| ----------------------------------------------------------------- |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get all the valid frequency keys. |
21
|
|
|
* |
22
|
|
|
* @return \Illuminate\Support\Collection |
23
|
|
|
*/ |
24
|
10 |
|
public static function keys() |
25
|
|
|
{ |
26
|
10 |
|
return new Collection([ |
27
|
10 |
|
static::ALWAYS, |
28
|
10 |
|
static::HOURLY, |
29
|
10 |
|
static::DAILY, |
30
|
10 |
|
static::WEEKLY, |
31
|
10 |
|
static::MONTHLY, |
32
|
10 |
|
static::YEARLY, |
33
|
10 |
|
static::NEVER, |
34
|
|
|
]); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Get all the valid frequency values. |
39
|
|
|
* |
40
|
|
|
* @param string|null $locale |
41
|
|
|
* |
42
|
|
|
* @return \Illuminate\Support\Collection |
43
|
|
|
*/ |
44
|
|
|
public static function all($locale = null) |
45
|
|
|
{ |
46
|
6 |
|
return static::keys()->mapWithKeys(function ($key) use ($locale) { |
47
|
6 |
|
return [$key => trans("sitemap::frequencies.$key", [], $locale)]; |
48
|
6 |
|
}); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get the translated frequency name. |
53
|
|
|
* |
54
|
|
|
* @param string $key |
55
|
|
|
* @param string|null $default |
56
|
|
|
* @param string|null $locale |
57
|
|
|
* |
58
|
|
|
* @return string|null |
59
|
|
|
*/ |
60
|
2 |
|
public static function get($key, $default = null, $locale = null) |
61
|
|
|
{ |
62
|
2 |
|
return static::all($locale)->get($key, $default); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Check if the given frequency exists. |
67
|
|
|
* |
68
|
|
|
* @param string $key |
69
|
|
|
* |
70
|
|
|
* @return bool |
71
|
|
|
*/ |
72
|
2 |
|
public static function has($key) |
73
|
|
|
{ |
74
|
2 |
|
return static::keys()->flip()->has($key); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|