コード例 #1
0
 /**
  * throws exceptions if $item is not a valid PCRE regex
  *
  * @param  string $item
  *         the container to check
  * @param  string $exception
  *         the class to use when throwing an exception
  * @return void
  */
 public static function checkString($item, $exception = E4xx_InvalidPcreRegex::class)
 {
     // make sure we have a stringy type
     if (!IsPcreRegex::checkString($item)) {
         throw new $exception($item);
     }
 }
コード例 #2
0
 /**
  * @covers ::checkString
  * @dataProvider provideInvalidRegexesToCheck
  */
 public function testReturnsFalseForValidRegexes($input, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = IsPcreRegex::check($input);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }