1
|
|
|
<?php namespace Arcanesoft\Seo\Helpers; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class SeoChecker |
5
|
|
|
* |
6
|
|
|
* @package Arcanesoft\Seo\Helpers |
7
|
|
|
* @author ARCANEDEV <[email protected]> |
8
|
|
|
*/ |
9
|
|
|
class SeoChecker |
10
|
|
|
{ |
11
|
|
|
/* ----------------------------------------------------------------- |
12
|
|
|
| Constants |
13
|
|
|
| ----------------------------------------------------------------- |
14
|
|
|
*/ |
15
|
|
|
const STATUS_DANGER = 'danger'; |
16
|
|
|
const STATUS_GOOD = 'good'; |
17
|
|
|
const STATUS_WARNING = 'warning'; |
18
|
|
|
|
19
|
|
|
/* ----------------------------------------------------------------- |
20
|
|
|
| Main Methods |
21
|
|
|
| ----------------------------------------------------------------- |
22
|
|
|
*/ |
23
|
|
|
/** |
24
|
|
|
* Check the title content. |
25
|
|
|
* |
26
|
|
|
* @param string $title |
27
|
|
|
* @param int $min |
28
|
|
|
* @param int $max |
29
|
|
|
* |
30
|
|
|
* @return string |
31
|
|
|
*/ |
32
|
|
|
public static function checkTitle($title, $min = 40, $max = 60) |
33
|
|
|
{ |
34
|
|
|
return self::check($title, $min, $max); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Check the description content. |
39
|
|
|
* |
40
|
|
|
* @param string $description |
41
|
|
|
* @param int $min |
42
|
|
|
* @param int $max |
43
|
|
|
* |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
|
|
public static function checkDescription($description, $min = 140, $max = 160) |
47
|
|
|
{ |
48
|
|
|
return self::check($description, $min, $max); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/* ----------------------------------------------------------------- |
52
|
|
|
| Other Methods |
53
|
|
|
| ----------------------------------------------------------------- |
54
|
|
|
*/ |
55
|
|
|
/** |
56
|
|
|
* Check the value with min & max length. |
57
|
|
|
* |
58
|
|
|
* @param string $value |
59
|
|
|
* @param int $min |
60
|
|
|
* @param int $max |
61
|
|
|
* |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
protected static function check($value, $min, $max) |
65
|
|
|
{ |
66
|
|
|
$length = strlen($value); |
67
|
|
|
|
68
|
|
|
if ($length < $min) |
69
|
|
|
return self::STATUS_WARNING; |
70
|
|
|
|
71
|
|
|
if ($min <= $length && $length <= $max) |
72
|
|
|
return self::STATUS_GOOD; |
73
|
|
|
|
74
|
|
|
return self::STATUS_DANGER; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|