Example #1
0
 /**
  * Add a number to the string
  *
  * @param string $string The string where the number will be appended to.
  * @return string
  */
 public static function addNumber($string)
 {
     // split
     $chunks = explode('-', $string);
     // count the chunks
     $count = count($chunks);
     // get last chunk
     $last = $chunks[$count - 1];
     // is nummeric
     if (SpoonFilter::isNumeric($last)) {
         // remove last chunk
         array_pop($chunks);
         // join together, and increment the last one
         $string = implode('-', $chunks) . '-' . ((int) $last + 1);
     } else {
         $string .= '-2';
     }
     return $string;
 }
 public function testIsNumeric()
 {
     $this->assertTrue(SpoonFilter::isNumeric('010192029'));
     $this->assertTrue(SpoonFilter::isNumeric(1337));
     $this->assertFalse(SpoonFilter::isNumeric('I can has cheezeburger'));
 }