1 | <?php |
||
14 | class Profile |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Traits |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | 1 | use Concerns\HashEmail; |
|
22 | |||
23 | /* ----------------------------------------------------------------- |
||
24 | | Constants |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | const BASE_URL = 'http://www.gravatar.com/'; |
||
29 | const SECURE_URL = 'https://www.gravatar.com/'; |
||
30 | |||
31 | /* ----------------------------------------------------------------- |
||
32 | | Properties |
||
33 | | ----------------------------------------------------------------- |
||
34 | */ |
||
35 | |||
36 | /** |
||
37 | * Profile's format. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $format; |
||
42 | |||
43 | /** |
||
44 | * Supported format. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected static $supportedFormat = ['json', 'xml', 'php', 'vcf', 'qr']; |
||
49 | |||
50 | /* ----------------------------------------------------------------- |
||
51 | | Getters & Setters |
||
52 | | ----------------------------------------------------------------- |
||
53 | */ |
||
54 | |||
55 | /** |
||
56 | * Get the profile's format. |
||
57 | * |
||
58 | * @return string|null |
||
59 | */ |
||
60 | 12 | public function getFormat(): ?string |
|
64 | |||
65 | /** |
||
66 | * Set the profile's format. |
||
67 | * |
||
68 | * @param string|null $format |
||
69 | * |
||
70 | * @return \Arcanedev\Gravatar\Profile |
||
71 | */ |
||
72 | 16 | public function setFormat(string $format = null) |
|
81 | |||
82 | /* ----------------------------------------------------------------- |
||
83 | | Main Methods |
||
84 | | ----------------------------------------------------------------- |
||
85 | */ |
||
86 | |||
87 | /** |
||
88 | * Build the profile URL based on the provided email address. |
||
89 | * |
||
90 | * @param string|null $email |
||
91 | * @param array $params |
||
92 | * @param bool $secure |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 12 | public function getUrl(string $email = null, array $params = [], bool $secure = true): string |
|
111 | |||
112 | /** |
||
113 | * Get the profile data. |
||
114 | * |
||
115 | * @param string $email |
||
116 | * @param mixed|null $default |
||
117 | * |
||
118 | * @return array|mixed |
||
119 | */ |
||
120 | 4 | public function get(string $email, $default = null) |
|
132 | |||
133 | /* ----------------------------------------------------------------- |
||
134 | | Check Methods |
||
135 | | ----------------------------------------------------------------- |
||
136 | */ |
||
137 | |||
138 | /** |
||
139 | * Check if the format is not null. |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | 12 | public function hasFormat(): bool |
|
147 | |||
148 | /** |
||
149 | * Check the format. |
||
150 | * |
||
151 | * @param string $format |
||
152 | */ |
||
153 | 16 | private static function checkFormat(string &$format): void |
|
161 | } |
||
162 |