1. <?php
  2. /**
  3.  * Aero PHP Framework
  4.  *
  5.  * LICENSE
  6.  *
  7.  * This source file is subject to the new BSD license that is bundled
  8.  * with this package in the file LICENSE.txt.
  9.  * It is also available through the world-wide-web at this URL:
  10.  * http://www.aeroframework.com/license/new-bsd
  11.  * If you did not receive a copy of the license and are unable to
  12.  * obtain it through the world-wide-web, please send an email
  13.  * to license@aeroframework.com so we can send you a copy immediately.
  14.  *
  15.  * @category Aero
  16.  * @package Aero\Validator
  17.  * @subpackage Email
  18.  * @copyright Copyright (c) 2009-2010 Xistins Technologies (http://www.xistins.com)
  19.  * @license http://www.aeroframework.com/license/new-bsd New BSD License
  20.  */
  21.  
  22. namespace Aero\Validator;
  23.  
  24. /**
  25.  * Email Validator
  26.  *
  27.  * @category Aero
  28.  * @package Aero\Validator
  29.  * @subpackage Email
  30.  * @copyright Copyright (c) 2009-2010 Xistins Technologies (http://www.xistins.com)
  31.  * @license http://www.aeroframework.com/license/new-bsd New BSD License
  32.  */
  33. class Email implements Structure
  34. {
  35. /**
  36.   * Is valid email
  37.   * Please note this is extremely simply but should work for most instances
  38.   *
  39.   * @param string $value Value to validate
  40.   * @return bool
  41.   */
  42. public function isValid($value)
  43. {
  44. if(!strpos($value, '@')) {
  45. return false;
  46. }
  47.  
  48. $parts = explode('@', $value);
  49. if(!strpos($parts[1], '.')) {
  50. return false;
  51. }
  52.  
  53. return (filter_var($value, FILTER_VALIDATE_EMAIL) === $value);
  54. }
  55. }