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