Pinq\Collection::from PHP Method

from() public static method

{@inheritDoc}
public static from ( $elements, Pinq\Iterators\IIteratorScheme $scheme = null, Traversable $source = null )
$scheme Pinq\Iterators\IIteratorScheme
$source Traversable
    public static function from($elements, Iterators\IIteratorScheme $scheme = null, Traversable $source = null)
    {
        if ($source !== null && !$source instanceof Collection) {
            throw new PinqException('Cannot construct %s: expecting source to be type %s or null, %s given', __CLASS__, __CLASS__, Utilities::getTypeOrClass($source));
        }
        return new static($elements, $scheme, $source);
    }

Usage Example

コード例 #1
0
 /**
  * @param string $basePath
  * @return Collection
  */
 public function extractPaths(string $basePath) : Collection
 {
     if (is_dir($basePath)) {
         return Collection::from(glob($basePath . '/*.md'));
     } else {
         return Collection::from([$basePath]);
     }
 }
All Usage Examples Of Pinq\Collection::from