Check if the given string represents a path to a readable file

@param string $file

@throws \InvalidArgumentException
187876
protected function isValidFile($file)
    {
        if (!is_file($file) || !is_readable($file)) {
            throw new \InvalidArgumentException(sprintf(
                    'File "%s" Is Not Readable', (string) $file
            ));
        }
    }
518192
public static function isLink(string $file = ''): bool
    {
        $file = static::normalizePath($file);
        return static::exists($file) && \is_link($file);
    }
29980
public function setFile($file)
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException('File not found: '.$file, ErrorCodes::FILE_NOT_FOUND);
        }
        if (!is_readable($file)) {
            throw new \InvalidArgumentException('File is not readable: '.$file, ErrorCodes::FILE_NOT_READABLE);
        }
        $this->file = $file;
        return $this;
    }
948570
public function import($file)
    {
        if (!file_exists($file)) {
            throw new \InvalidArgumentException("Footprint file '$file' does not exist");
        }
        $content = file_get_contents($file);
        $this->importJson($content);
    }
265822
public static function validatePath(string $path = null): void
    {
        if (empty($path)) {
            throw new InvalidArgumentException("Cannot validate empty path");
        }

        if (!file_exists($path)) {
            throw new InvalidArgumentException("Path does not exist [$path]");
        }
        if (!is_readable($path)) {
            throw new InvalidArgumentException("Path is not readable [$path]");
        }
    }
638517
public function parse($file)
	{
		$this->openFile($file);

		switch (strtolower($this->extension)) {
			case 'json':
			return json_decode($this->readFile());
			case 'ini':
			return (object)parse_ini_string($this->readFile(), true);
			case 'xml':
			return simplexml_load_string($this->readFile());
			case 'csv':
			return array_map(
				'str_getcsv',
				explode(PHP_EOL, trim($this->readFile()))
			);
			default:
				throw new \InvalidArgumentException(
					"{$this->extension} is not a supported extension."
				);
		}
	}
424496
private function checkFile(string &$file): bool
    {
        $file = "{$this->directory}/{$file}";

        return file_exists($file) || (touch($file) && chmod($file, 0600));
    }
616286
public function validateFile(File $file)
    {
        if (!$this->acceptsExtension($file->getExtension())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with extension %s", $file->getExtension()));
        }

        if (!$this->acceptsMime($file->getMime())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime of %s", $file->getMime()));
        }

        if (!$this->acceptsMimeType($file->getMimeType())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime type of %s", $file->getMimeType()));
        }

        if (!$this->acceptsMimeEncoding($file->getMimeEncoding())) {
            throw new Exception\InvalidFileException(sprintf("This definition does not accept files with mime encoding of %s", $file->getMimeEncoding()));
        }

        if ($this->getRequiredType()) {
            if ($this->getRequiredType() !== $file->getType()) {
                throw new Exception\InvalidFileException(sprintf("This definition only accept files of type %s", $this->getRequiredType()));
            }
        }

        if (!$this->getAllowDirectory() && $file->isDir()) {
            throw new Exception\InvalidFileException("This definition cannot accept a directory as input");
        }

        return true;
    }
429907
public static function remove(string $file = ''): bool
    {
        $file = static::normalizePath($file);
        if (static::exists($file)) {
            return @\unlink($file);
        }
        return false;
    }
853134
final public function hasFile($file)
	{
		$helloReflection = new \ReflectionClass($this);
		$dir = dirname($helloReflection->getFilename());

		if(file_exists($dir . '/' . $file)) {
			return $dir . '/' . $file;
		}
		return false;
	}
519386
public static function isFileReadable($file)
    {
        $result = false;

        if (!file_exists($file)) {
            return $result;
        }
        if (!is_file($file)) {
            return $result;
        }
        if (!is_readable($file)) {
            return $result;
        }

        $result = true;

        return $result;
    }
796000
public static function read(string $file = ''): string
    {
        $result = false;
        $file = static::normalizePath($file);

        if (static::exists($file)) {
            $result = @\file_get_contents($file);
        }

        return $result;
    }
181766
public static function rmfile($file)
    {
        if (is_file($file)) {
            return chmod($file, 0777) && unlink($file);
        } else {
            throw new RuntimeException(sprintf(
                'Invalid file path supplied "%s"', $file
            ));
        }
    }
940203
private function shouldCopyFileInstead($file)
    {
        // Check if it should not be processed.
        if ($this->isExcludedFromVerbatim($file)) {
            return false;
        }

        foreach ($this->copyVerbatimPatterns as $pattern) {
            if (Str::is($pattern, $file)) {
                return true;
            }
        }

        return false;
    }
1211887
private function validate($content, $file)
    {
        if (null === $content) {
            return $content;
        }

        if (!is_array($content)) {
            throw new \InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
        }

        foreach (array_keys($content) as $namespace) {
            if (in_array($namespace, ['imports', 'parameters'])) {
                continue;
            }
        }

        return $content;
    }
82621
private function lintFile($file)
    {
        // first try to parse it
        try {
            $this->parser->parse(\file_get_contents($file));
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
533705
protected function parseFile($file)
    {
        try {
            $dom = XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH);
        } catch (\InvalidArgumentException $e) {
            throw new \InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
        }

        return $dom;
    }