src/PatchCollector.php
protected function resolveJsonFile(PackageInterface $package, $jsonPath)
    {
        $collectedPatches = new PatchCollection();
        if (!is_string($jsonPath) || $jsonPath === '') {
            $this->handleException(Exception\InvalidPackageConfigurationValue($package(), 'extra.patches-file', $jsonPath, 'The extra.patches-file configuration must be a non empty string.'));
        } else {
            $packageDirectory = $this->installationManager->getInstallPath($package);
            $fullJsonPath = $this->pathResolver->resolve($jsonPath, $packageDirectory);
            $jsonReader = new JsonFile($fullJsonPath, null, $this->io);
            $data = $jsonReader->read();
            if (!is_array($data)) {
                $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches-file', $jsonPath, "The JSON file at \"{$jsonPath}\" must contain an array."));
            } elseif (!isset($data['patches'])) {
                $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches-file', $jsonPath, "The JSON file at \"{$jsonPath}\" must contain an array with a \"patches\" key."));
            } else {
                $collectedPatches->merge($this->resolveExplicitList($package, $data['patches']));
            }
        }

        return $collectedPatches;
    }
protected function resolveJsonFile(PackageInterface $package, $jsonPath)
    {
        $collectedPatches = new PatchCollection();
        if (!is_string($jsonPath) || $jsonPath === '') {
            $this->handleException(Exception\InvalidPackageConfigurationValue($package(), 'extra.patches-file', $jsonPath, 'The extra.patches-file configuration must be a non empty string.'));
        } else {
            $packageDirectory = $this->installationManager->getInstallPath($package);
            $fullJsonPath = $this->pathResolver->resolve($jsonPath, $packageDirectory);
            $jsonReader = new JsonFile($fullJsonPath, null, $this->io);
            $data = $jsonReader->read();
            if (!is_array($data)) {
                $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches-file', $jsonPath, "The JSON file at \"{$jsonPath}\" must contain an array."));
            } elseif (!isset($data['patches'])) {
                $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches-file', $jsonPath, "The JSON file at \"{$jsonPath}\" must contain an array with a \"patches\" key."));
            } else {
                $collectedPatches->merge($this->resolveExplicitList($package, $data['patches']));
            }
        }

        return $collectedPatches;
    }
protected function resolveJsonFile ( PackageInterface $ package , $ jsonPath ) { $ collectedPatches = new PatchCollection ( ) ; if ( ! is_string ( $ jsonPath ) || $ jsonPath === '' ) { $ this -> handleException ( Exception \ InvalidPackageConfigurationValue ( $ package ( ) , 'extra.patches-file' , $ jsonPath , 'The extra.patches-file configuration must be a non empty string.' ) ) ; } else { $ packageDirectory = $ this -> installationManager -> getInstallPath ( $ package ) ; $ fullJsonPath = $ this -> pathResolver -> resolve ( $ jsonPath , $ packageDirectory ) ; $ jsonReader = new JsonFile ( $ fullJsonPath , null , $ this -> io ) ; $ data = $ jsonReader -> read ( ) ; if ( ! is_array ( $ data ) ) { $ this -> handleException ( Exception \ InvalidPackageConfigurationValue ( $ package , 'extra.patches-file' , $ jsonPath , "The JSON file at \"{$jsonPath}\" must contain an array." ) ) ; } elseif ( ! isset ( $ data [ 'patches' ] ) ) { $ this -> handleException ( Exception \ InvalidPackageConfigurationValue ( $ package , 'extra.patches-file' , $ jsonPath , "The JSON file at \"{$jsonPath}\" must contain an array with a \"patches\" key." ) ) ; } else { $ collectedPatches -> merge ( $ this -> resolveExplicitList ( $ package , $ data [ 'patches' ] ) ) ; } } return $ collectedPatches ; }
Collect the patches from the "patches-file" configuration key.

@param \Composer\Package\PackageInterface $package the package being inspected
@param string|mixed $jsonPath the extra.patches-file configuration provided by the package

@throws \ComposerPatcher\Exception\InvalidPackageConfigurationValue when $jsonPath is not valid

@return \ComposerPatcher\PatchCollection
Collect the patches from the patches - file configuration key .