/**
  * {@inherit-doc}.
  *
  * @param string    $file
  * @param true|bool $single
  *
  * @return array
  */
 public function locate($file, $single = true)
 {
     if (true !== $this->search instanceof FixturePathsInterface) {
         return [];
     }
     $paths = $this->locateValidPaths($file)->getPaths();
     return (array) ($single ? getFirstArrayElement($paths) : $paths);
 }
Beispiel #2
0
 /**
  * Call a global function or class method (if exists) or callable with specified arguments.
  *
  * @param string|array|\Closure $what      A global function name or class method (if exists) or callable
  * @param mixed,...             $arguments Arguments to pass to the global function
  *
  * @return mixed
  */
 public static function this($what, ...$arguments)
 {
     if (is_string($what)) {
         return static::handle($what, null, null, ...$arguments);
     }
     if (is_array($what)) {
         return static::handle(getLastArrayElement($what), getFirstArrayElement($what), false, ...$arguments);
     }
     if ($what instanceof \Closure) {
         return $what(...$arguments);
     }
     throw InvalidArgumentException::create()->setMessage('Invalid call requested (got "%s" with parameters "%s").', var_export($what, true), var_export($arguments, true));
 }
 /**
  * @return string
  */
 protected function resolveLocation()
 {
     $location = $this->locator->locate($this->fileName);
     return (string) getFirstArrayElement($location);
 }
Beispiel #4
0
 public function testGetArrayFirstOnNonArrayAccess()
 {
     static::assertNull(getFirstArrayElement('not-iterable'));
 }