Устанавливает путь к файлу.
@param string $filePath путь к файлу
@throws InvalidArgumentException если файл не существует или находится не в заданной директории
@return $this
6677
public function setFilePath($filePath)
    {
        $splFileInfo = new \SplFileInfo($filePath);
        if (!$realFilePath = $splFileInfo->getRealPath()) {
            throw new InvalidArgumentException(
                sprintf('Cannot set file path. File "%s" does not exist.', $filePath)
            );
        }

        if (strpos($realFilePath, $this->sourcePath) !== 0) {
            throw new InvalidArgumentException(
                sprintf('Cannot set file path. File path "%s" does not match source path.', $filePath)
            );
        }

        if (is_null($this->splFileInfo) || $this->splFileInfo->getRealPath() != $realFilePath) {

            $this->splFileInfo = $splFileInfo;

            $relativePath = str_replace($this->sourcePath, '', $realFilePath);
            $this->fileURI = $this->sourceURI . $relativePath;

            $this->property->update();
        }

        return $this;
    }
47295
public function setFileType(/*# string */ $fileType)
    {
        if (!Reader::isSupported($fileType)) {
            throw new InvalidArgumentException(
                Message::get(Message::CONFIG_FILE_TYPE_UNKNOWN, $fileType),
                Message::CONFIG_FILE_TYPE_UNKNOWN
            );
        }

        $this->file_type = $fileType;
        return $this;
    }
1139384
public function setFontPath($fontPath)
    {
        if (is_file($fontPath)) {
            $this->fontTruetype = true;
            $this->fontPath = $fontPath;
        }

        return $this;
    }
1242106
private function loadConfiguration($filePath)
    {
        if (!is_file($filePath)) {
            throw new \InvalidArgumentException(sprintf('The configuration file "%s" does not exit', $filePath));
        }

        $config = include $filePath;

        if (!$config instanceof Configuration) {
            throw new \InvalidArgumentException(
                sprintf(
                    'The configuration file "%s" must return a "Akeneo\CouplingDetector\Configuration\Configuration"',
                    $filePath
                )
            );
        }

        return $config;
    }
460699
public function attachFile(string $filePath, string $name = null)
    {
        $this->mailer->addAttachment($filePath, $name ?? '');
        return $this;
    }
1186239
private function makePathRelative($filePath)
    {
        $thisFilePath = __FILE__;
        $thisFilePathParts = explode('/src/', $thisFilePath);
        $projectRootDir = $thisFilePathParts[0].DIRECTORY_SEPARATOR;

        return str_replace($projectRootDir, '', $filePath);
    }
149401
public static function getInstance($filePath = "/data/config/", $fileExt = "json")
    {
        if (!self::$instance) {
            self::$instance = new self($filePath, $fileExt);
        }

        return self::$instance;
    }
1176884
private function inflate($filePath)
    {
        $currentDirectory = rtrim(dirname($this->currentView), self::DS);
        $currentDirectory .= self::DS;
        if (substr($filePath, -6, 6) != '.phtml') {
            $filePath .= '.phtml';
        }

        $searchPath = realpath($currentDirectory . $filePath);
        if ($searchPath != false && file_exists($searchPath)) {
            $content = @include $searchPath;
            if (!$content) {
                // @codeCoverageIgnoreStart
                $e = new ViewFileNotFoundException('Unable to inflate file "' . $searchPath . '"');
                $e->setAdditionalData('View Path: ', $searchPath);
                throw $e;
                // @codeCoverageIgnoreEnd
            }
            return;
        }

        // @codeCoverageIgnoreStart
        $e = new ViewFileNotFoundException('Invalid view file path, expected: "' . $currentDirectory . $filePath . '"');
        $e->setAdditionalData('View Path Checked: ', $currentDirectory . $filePath);
        throw $e;
        // @codeCoverageIgnoreEnd
    }
429196
public function setFilePath($filePath)
    {
        Assert::stringNotEmpty($filePath, 'The factory file path must be a non-empty string. Got: %s');

        $this->setDirectory(Path::getDirectory($filePath));
        $this->setFileName(Path::getFilename($filePath));

        return $this;
    }
33256
public static function create(string $filePath): UnreadableVersionFileException
    {
        $template = 'File %s, who contains version of the application, is not readable. Does the file exist?';
        $message = sprintf($template, $filePath);

        return new static($message);
    }
1241289
public function setWebRootPath($path)
    {
        if (@file_exists($path) && is_dir($path)) {
            $this->web_root_path = realpath($path).'/';
        } else {
            throw new \InvalidArgumentException(
                sprintf('Web root path "%s" was not found or is not a directory!', $path)
            );
        }
        return $this;
    }
1080579
public function loadYamlFile($filePath)
    {
        if (file_exists($filePath)) {
            $this->loadYaml(file_get_contents($filePath));

            return $this;
        }

        return $this;
    }
916516
protected function openFile($filePath)
    {
        if (empty($filePath)) {
            throw new \Exception('Input file not defined.');
        } elseif (!file_exists($filePath)) {
            throw new \Exception("File does not exist: {$filePath}");
        }

        $handle = @fopen($filePath, 'r');
        if (false === $handle) {
            throw new \Exception("Unable to open file for reading: {$filePath}");
        }

        return $handle;
    }
709154
public static function fromFile($filePath, $mode = self::MODE_READ, $format = Format::AUTO) {
        $format = FormatFactory::getInstance()->getFormat($format, $filePath, $mode);
        return new static($format);
    }
18654
public static function create($filePath)
    {
        if (!file_exists($filePath)) {
            throw new Exception(["{$filePath} has not been found"]);
        }

        $file = fopen($filePath, 'r');

        $photo = json_decode(
            self::post(
                "photos",
                [
                    'multipart' => [['name' => 'photo', 'contents' => $file]],
                    'headers' => ['Content-Length' => filesize($filePath)]
                ]
            )->getBody(),
            true
        );

        return new self($photo);
    }
136674
public function addFiles($filePaths): self
    {
        if (is_string($filePaths)) {
            $filePaths = [$filePaths];
        }

        foreach ($filePaths as $filePath) {
            if (! empty($filePath)) {
                file_put_contents($this->manifestPath, $filePath.PHP_EOL, FILE_APPEND);
            }
        }

        return $this;
    }
244976
public function setFile($filePath = '.gitignore')
    {
        $this->fileContent = array();
        $this->afterLine = null;
        $this->filePath = $filePath;
        $this->checkPermissions();
        $this->parse();
    }