1: <?php
2:
3: /**
4: * PhpOptions
5: * @link https://github.com/masicek/PhpOptions
6: * @author Viktor Mašíček <viktor@masicek.net>
7: * @license "New" BSD License
8: */
9:
10: namespace PhpOptions\Types;
11:
12: require_once __DIR__ . '/AType.php';
13:
14: /**
15: * Email type
16: *
17: * @author Viktor Mašíček <viktor@masicek.net>
18: */
19: class EmailType extends AType
20: {
21:
22:
23: /**
24: * Check type of value.
25: *
26: * @param mixed $value Checked value
27: *
28: * @return bool
29: */
30: public function check($value)
31: {
32: return (bool)preg_match('/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+[.][a-zA-Z]{2,4}/', $value);
33: }
34:
35:
36: }
37: