Example #1
0
 public function testIsValid()
 {
     $validator = new VRM();
     $valid = array('AA01 AAA', 'a123 aaa', 'bbc 1 a', '1bbc', 'tac 220', 't 22');
     $invalid = array('AA01 IAA');
     foreach ($valid as $vrm) {
         $this->assertTrue($validator->isValid($vrm), sprintf('VRM %s is not valid', $vrm));
     }
     foreach ($invalid as $vrm) {
         $this->assertFalse($validator->isValid($vrm), sprintf('VRM %s is valid', $vrm));
     }
 }
Example #2
0
 /**
  * Proxy method for strB2BGetVehicleByVRM
  *
  * @param string $vrm
  * @param string $strClientRef
  * @param string $strClientDescription
  * @return mixed|void
  */
 public function findByVRM($vrm, $strClientRef = 'default client', $strClientDescription = 'Carweb PHP Library')
 {
     $vrm = strtoupper(preg_replace('/\\s+/', '', $vrm));
     $validator = new VRM();
     if (!$validator->isValid($vrm) && $this->validate) {
         throw new ValidationException('Invalid UK VRM');
     }
     $api_method = 'strB2BGetVehicleByVRM';
     $cache_key = sprintf('%s.%s', $api_method, $vrm);
     $converter = $this->getConverter($api_method);
     if ($this->isCached($cache_key)) {
         $content = $this->getCached($cache_key);
         return $converter->convert($content);
     }
     $input = array('strUserName' => $this->strUserName, 'strPassword' => $this->strPassword, 'strKey1' => $this->strKey1, 'strVersion' => self::API_VERSION, 'strVRM' => $vrm, 'strClientRef' => $strClientRef, 'strClientDescription' => $strClientDescription);
     $content = $this->call($api_method, RequestInterface::METHOD_GET, $input);
     $this->setCached($cache_key, $content);
     return $converter->convert($content);
 }