示例#1
0
 /**
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     if (empty($value)) {
         $this->_error(self::IS_EMPTY);
         return false;
     }
     if (!is_string($value)) {
         $this->_error(self::NOT_A_STRING);
         return false;
     }
     $parts = explode('.', $value);
     if (count($parts) != 3) {
         $this->_error(self::INVALID);
         return false;
     }
     $buildIdValidator = new BuildIdValidator();
     if (!$buildIdValidator->isValid($parts[0])) {
         $this->_error(self::INVALID);
         return false;
     }
     $integerValidator = new IntegerValidator();
     if (!$integerValidator->isValid($parts[1])) {
         $this->_error(self::INVALID);
         return false;
     }
     $uniqueIdValidator = new UniqueIdValidator('', '');
     if (!$uniqueIdValidator->isValid($parts[2])) {
         $this->_error(self::INVALID);
         return false;
     }
     return true;
 }
示例#2
0
文件: Cdn.php 项目: rukzuk/rukzuk
 /**
  * @param  int $id
  * @return boolean
  */
 private function validateBuildId($id, $key = 'buildid')
 {
     $buildIdValidator = new BuildIdValidator();
     if (!$buildIdValidator->isValid($id)) {
         $messages = array_values($buildIdValidator->getMessages());
         $this->addError(new Error($key, $id, $messages));
         return false;
     }
     return true;
 }
示例#3
0
 /**
  * @test
  * @group small
  * @group dev
  * @group library
  * @dataProvider validBuildIdsProvider
  */
 public function isValidShouldReturnTrueForValidBuildIdValues($id)
 {
     $validator = new BuildIdValidator();
     $this->assertTrue($validator->isValid($id));
 }