<commit_before><?php

/**
 * This file is part of the Dealerdirect PHP_CodeSniffer Standards
 * Composer Installer Plugin package.
 *
 * @copyright 2016 Dealerdirect B.V.
 * @license MIT
 */

namespace Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer;

use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;

/**
 * PHP_CodeSniffer standard installation manager.
 *
 * @author <NAME> <<EMAIL>>
 */
class Installer extends LibraryInstaller
{
    /**
     * {@inheritDoc}
     */
    public function getInstallPath(PackageInterface $package)
    {
        $this->initializeVendorDir();

        $rootPackageExtra = $this->composer->getPackage()->getExtra();
        $packageExtra     = $package->getExtra();

        if (isset($rootPackageExtra['phpcodesniffer-mapping'][$package->getPrettyName()]) === true) {
            $standardDir = $rootPackageExtra['phpcodesniffer-mapping'][$package->getPrettyName()];
        } elseif (isset($packageExtra['phpcodesniffer-standard']) === true) {
            $standardDir = $packageExtra['phpcodesniffer-standard'];
        } else {
            $standardDir = $this->generateStandardNameFromPackage($package);
        }

        return implode(
            DIRECTORY_SEPARATOR,
            [
                $this->vendorDir ? $this->vendorDir : '.',<commit_msg>Look for standards mappings in other packages of the local repository (e.g. in case this was provided by a metapackage)<commit_after><?php

/**
 * This file is part of the Dealerdirect PHP_CodeSniffer Standards
 * Composer Installer Plugin package.
 *
 * @copyright 2016 Dealerdirect B.V.
 * @license MIT
 */

namespace Dealerdirect\Composer\Plugin\Installers\PHPCodeSniffer;

use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;

/**
 * PHP_CodeSniffer standard installation manager.
 *
 * @author <NAME> <<EMAIL>>
 */
class Installer extends LibraryInstaller
{
    /**
     * {@inheritDoc}
     */
    public function getInstallPath(PackageInterface $package)
    {
        $this->initializeVendorDir();

        $packages   = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
        $packages[] = $this->composer->getPackage();

        $mapping = [];
        foreach($packages as $localPackage) {
          $extra = $localPackage->getExtra();
          if (isset($extra['phpcodesniffer-mapping']) === true) {
            $mapping = array_merge($mapping, $extra['phpcodesniffer-mapping']);
          }
        }

        $packageExtra = $package->getExtra();

        if (isset($mapping[$package->getPrettyName()]) === true) {
            $standardDir = $mapping[$package->getPrettyName()];
        } elseif (isset($packageExtra['phpcodesniffer-standard']) === true) {
            $standardDir = $packageExtra['phpcodesniffer-standard'];
        } else {
            $standardDir = $this->generateStandardNameFromPackage($package);
        }

        return implode(
            DIRECTORY_SEPARATOR,
            [
                $this->vendorDir ? $this->vendorDir : '.',
{'fraction_non_alphanumeric': 0.13418217433888344, 'fraction_numerical': 0.002611818478615736, 'mean_word_length': 3.074468085106383, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2438048', 'n_tokens_mistral': 859, 'n_tokens_neox': 832, 'n_words': 163}