Example #1
0
 /**
  * Accepts a string to set the Sequence prefix/sequence values to, in the
  * format PREFIX-00000000000.
  *
  * @param string $val
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\IllegalArguementException
  */
 public function setValue($val)
 {
     if (mb_strlen($val) <= $this->size) {
         if (!empty($val)) {
             if (!Validator::isSequence($val)) {
                 throw new IllegalArguementException($this->helper);
             }
             $parts = explode('-', $val);
             $this->prefix->setValue($parts[0]);
             $this->sequence->setValue($parts[1]);
         }
     } else {
         throw new IllegalArguementException($this->helper);
     }
 }
Example #2
0
 /**
  * Validate that the provided value is a valid Sequence value.
  *
  * @since 1.0
  */
 public function testIsSequence()
 {
     $this->assertTrue(Validator::isSequence('BARS-150'));
     $this->assertTrue(Validator::isSequence('ALPH-15'));
     $this->assertTrue(Validator::isSequence('DESI-1'));
     $this->assertFalse(Validator::isSequence('1'));
     $this->assertFalse(Validator::isSequence('1.0'));
     $this->assertFalse(Validator::isSequence('DESI8'));
 }