Example #1
0
 /**
  * Start the bootstrapping process
  * @return boolean
  */
 private function Bootstrap()
 {
     if (!empty($this->dir)) {
         $files = scandir($this->dir, SCANDIR_SORT_ASCENDING);
         $units = array();
         foreach ($files as $key => $file) {
             if (\BTRString::EndsWith($file, ".php")) {
                 $path = $this->dir . "{$file}";
                 include $path;
                 $units[] = $path;
             }
         }
         foreach ($units as $value) {
             $name = basename($value, ".php");
             $unit = new $name();
             $this->AddUnit($unit);
         }
         return true;
     } else {
         return false;
     }
 }
 public function testSubStrClauseNoDot()
 {
     $sentence = "This is the example sentence with should be terminated after the This content will not be included anymore";
     $got = \BTRString::SubStrClause($sentence, 1) == "This is the example sentence with should be terminated after the This content will not be included anymore";
     $this->assertTrue($got);
 }
Example #3
0
 /**
  * Applies a regex search on the array values
  * @param array $haystack the array to search in
  * @param string $needle the regex
  * @return boolean
  */
 static function Match($haystack, $needle)
 {
     if (empty($haystack) || empty($needle) || !is_string($needle)) {
         return false;
     }
     foreach ($haystack as $value) {
         if (is_array($value) || is_object($value)) {
             $sub = \BTRArray::Match($value, $needle);
         } else {
             $sub = \BTRString::Match($value, $needle);
         }
         if ($sub === true) {
             return true;
         }
     }
     return false;
 }