pharext\License::findLicense PHP Method

findLicense() public method

public findLicense ( $dir, $file = null )
    function findLicense($dir, $file = null)
    {
        if (isset($file)) {
            return realpath("{$dir}/{$file}");
        }
        $names = [];
        foreach (["{,UN}LICEN{S,C}{E,ING}", "COPY{,ING,RIGHT}"] as $name) {
            $names[] = $this->mergeLicensePattern($name, strtolower($name));
        }
        $exts = [];
        foreach (["t{,e}xt", "rst", "asc{,i,ii}", "m{,ark}d{,own}", "htm{,l}"] as $ext) {
            $exts[] = $this->mergeLicensePattern(strtoupper($ext), $ext);
        }
        $pattern = "{" . implode(",", $names) . "}{,.{" . implode(",", $exts) . "}}";
        if ($glob = glob("{$dir}/{$pattern}", GLOB_BRACE)) {
            return current($glob);
        }
    }