Simple helper function to check validity of provided extension name

@param   string  $extension  Extension name to evaluate
@param   string  $base       Directory to examine
@return  bool
433091
private function isValidExtension($extension, $base)
	{
		$ext = explode('_', $extension);
		$dir = '';

		switch ($ext[0])
		{
			case 'com':
				$dir = $base . DS . 'components' . DS . $extension;
			break;
			case 'mod':
				$dir = $base . DS . 'modules' . DS . $extension;
			break;
			case 'plg':
				$dir = $base . DS . 'plugins' . DS . $ext[1] . DS . $ext[2];
			break;
			default:
				return false;
			break;
		}

		return (is_dir($dir)) ? true : false;
	}
338894
private function isAllowedExtension($extension = null)
    {
        if(!$extension && $this->extension) {
            $extension = $this->extension;
        }

        if(!$extension) {
            throw new \Exception("No extension given");
        }

        if(array_intersect([strtolower($extension),strtoupper($extension)], self::allowedExtensions())) {
            return true;
        }
        return false;
    }
1340536
public static function isCompiled( $compiledDir, $basename )
	{
		$extensions = array( 'json', 'zip' );
		// Make sure the dir ends in /
		$compiledDir = rtrim( $compiledDir, '/' ) . "/";

		foreach ( $extensions as $extension )
		{
			$compiledFile = "$compiledDir$basename.$extension";
			if ( ! file_exists( $compiledFile ) ) continue;
			return $compiledFile;
		}

		return false;
	}
1233941
public function findFirstWithExtension($extension)
	{
		foreach ($this->getFlatListOfFiles() as $file)
		{
			if ($file->hasExtension($extension))
			{
				return $file;
			}
		}

		return false;
	}
1125182
public function name()
    {
        if (!$this->info) {
            $this->info();
        }
        if (isset($this->info['extension'])) {
            return static::_basename($this->name, '.' . $this->info['extension']);
        }
        if ($this->name) {
            return $this->name;
        }

        return false;
    }
1372951
public function isBasePart($base)
    {
        if (empty($base)) {
            $this->_status &= ~self::STATUS_BASEPART;
        } else {
            $this->_status |= self::STATUS_BASEPART;
        }
    }
658117
public function extension(string $name): bool
    {
        $files = $this->app->make('files');

        list($basePath, $sourcePath) = $this->getPathFromExtensionName($name);

        $paths = [
            "{$basePath}/resources/database/migrations/",
            "{$basePath}/resources/migrations/",
            "{$basePath}/database/migrations/",
        ];

        // We don't execute the same migration twice, this little code
        // compare both folder before appending the paths.
        if ($basePath !== $sourcePath && ! empty($sourcePath)) {
            $paths = array_merge($paths, [
                "{$sourcePath}/resources/database/migrations/",
                "{$sourcePath}/resources/migrations/",
                "{$sourcePath}/database/migrations/",
            ]);
        }

        foreach ($paths as $path) {
            if ($files->isDirectory($path)) {
                $this->run($path);
            }
        }

        return true;
    }
10932
def _is_valid_extension(extension):
    
    if not cfg.CONF.valid_extensions:
        return True

    valid = False
    for cext in cfg.CONF.valid_extensions:
        if not cext.startswith('.'):
            cext = '.%s' % cext
        if extension == cext:
            valid = True
            break

    return valid
671682
public function hasSettingsForm(ExtensionContract $extension) : bool {
        $className = $extension->getRootNamespace() . self::$formClassName;

        return class_exists($className);
    }
198886
public function getName($extension = self::WITH_EXTENSION) {
    if (isset($this->extension) && $extension == self::WITH_EXTENSION)
      return $this->name.'.'.$this->extension;
    else
      return $this->name;
  }
1055003
public function checkExtension($extension)
    {
        // Check for HHVM and built-in extensions
        if ($this->php()->isHhvm()) {
            $this->extensions = [
                '_hhvm',
                'apache',
                'asio',
                'bcmath',
                'bz2',
                'ctype',
                'curl',
                'debugger',
                'fileinfo',
                'filter',
                'gd',
                'hash',
                'hh',
                'iconv',
                'icu',
                'imagick',
                'imap',
                'json',
                'mailparse',
                'mcrypt',
                'memcache',
                'memcached',
                'mysql',
                'odbc',
                'openssl',
                'pcre',
                'phar',
                'reflection',
                'session',
                'soap',
                'std',
                'stream',
                'thrift',
                'url',
                'wddx',
                'xdebug',
                'zip',
                'zlib',
            ];
        }

        // Get the PHP extensions available
        if (!$this->extensions) {
            $this->extensions = (array) $this->bash->run($this->php()->extensions(), false, true);
        }

        return in_array($extension, $this->extensions, true);
    }
791859
public static function check($filename, array $allowedExtension)
    {
        $ext = pathinfo($filename, PATHINFO_EXTENSION);

        if (empty($ext)) {
            return false;
        }

        return in_array($ext, $allowedExtension);
    }
1196593
protected function removeExtensionFromFilename($filename, $extension)
    {
        $extension = '.'.$extension;
        $extension_length = mb_strlen($filename) - mb_strlen($extension);
        if (mb_strrpos($filename, $extension) === $extension_length) {
            $filename = mb_substr($filename, 0, $extension_length);
        }

        return $filename;
    }
560321
public function qualify($url, $base)
    {
        if(!parse_url($url, PHP_URL_SCHEME))
        {
            if ($url[0] != '/')
            {
                //Relative path
                $url = dirname($base) . '/' . $url;
            }
            else
            {
                //Absolute path
                $url = parse_url($base, PHP_URL_SCHEME) . ':/' . $url;
            }
        }

        return $this->normalise($url);
    }
820076
public static function fromExtension($extension)
	{
		$extension = strtolower($extension);

		return isset(static::$mimetypes[$extension])
			? static::$mimetypes[$extension]
			: null;
	}
1021494
public function validExt($filename){
        $exts = $this->config['ext'];
        $ext = $this->getExtension($filename);
        if(array_search($ext,$exts)===false){
            return false;
        }else{
            return true;
        }


    }
610134
public function isValid(ExtensionContract $extension) : bool {
        return ! in_array($extension->getPackage()->getName(), $this->configRepository->getReservedNames(), true);
    }