コード例 #1
0
 /**
  * {@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);
 }
コード例 #2
0
ファイル: Call.php プロジェクト: scr-be/wonka-library
 /**
  * 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));
 }
コード例 #3
0
 /**
  * @return string
  */
 protected function resolveLocation()
 {
     $location = $this->locator->locate($this->fileName);
     return (string) getFirstArrayElement($location);
 }
コード例 #4
0
 public function testGetArrayFirstOnNonArrayAccess()
 {
     static::assertNull(getFirstArrayElement('not-iterable'));
 }