Exemple #1
0
 public function testContains()
 {
     $string = "yo, i am here";
     $this->assertTrue(Str::contains($string, 'here'));
     $this->assertFalse(Str::contains($string, 'beer'));
     $this->assertContains('am', Str::contains($string, ['low', 'blow', 'yo', 'am']));
     $res = Str::contains($string, ['low', 'blow', 'yo', 'am']);
     $this->assertContains('am', $res);
     $this->assertContains('yo', $res);
     $this->assertFalse(Str::contains($string, ['low', 'blow']));
 }
Exemple #2
0
 /**
  * @param $namespace
  * @throws \Exception
  */
 private function findAndInclude($namespace)
 {
     $finder = new Finder();
     $namespaceParts = explode('\\', $namespace);
     $class = array_pop($namespaceParts);
     $finder->name($class . '.php');
     $finder->in(getcwd() . $this->vendorExtension);
     //local vendor dir
     if (iterator_count($finder) === 0) {
         throw new \Exception('Cannot find detected class');
     }
     foreach ($finder as $file) {
         //TODO - there must be a better way to do this? Seems inefficient if we are checking namespace and path. Why not just check the path?
         if ($file->isFile() && (Str::contains($file->getRelativePath(), 'RoboCommand') !== false || Str::contains($file->getRelativePath(), 'Command'))) {
             include_once $file->getRealPath();
         }
     }
 }