<commit_before><?php

namespace MarkWilson\Composer;

use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Package\Package;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Symfony\Component\Filesystem\Filesystem;

/**
 * Wordpress plugin
 *
 * @package MarkWilson\Composer
 * @author  <NAME> <<EMAIL>>
 */
class WordpressPlugin implements PluginInterface, EventSubscriberInterface
{
    /**
     * Root package
     *
     * @var Package
     */
    private $package;

    /**
     * IO
     *
     * @var IOInterface
     */
    private $io;

    /**
     * Project root
     *
     * @var string
     */
    private $projectRoot;

    /**
     * Activate Wordpress plugin
     *
     * @param Composer    $composer Composer
     * @param IOInterface $io       IO
     *
     * @return void
     */
    public function activate(Composer $composer, IOInterface $io)
    {
        $this->package = $composer->getPackage();
        $this->io = $io;

        // TODO: get the project root - must be a better way to do this
        $this->projectRoot = dirname($composer->getConfig()->get('vendor-dir'));
    }

    /**
     * Get the subscribed events
     *
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return array(
            ScriptEvents::POST_INSTALL_CMD => array(
                array('initialiseWordpress', 0)
            ),
            ScriptEvents::POST_UPDATE_CMD => array(
                array('initialiseWordpress', 0)
            ),
        );
    }

    /**
     * Initialise the project
     *
     * @param Event $event Event
     *
     * @return void
     */
    public function initialiseWordpress(Event $event)
    {
        $webroot = $this->getWebroot();
        $devMode = $this->isDevMode();

        $this->copyIndex($webroot, $devMode);
        $this->copyContent($webroot, $devMode);
        $this->copyAssets($webroot, $devMode);
    }

    /**
     * Are we in dev mode?
     *
     * @return boolean
     */
    private function isDevMode()
    {
        return $this->package->isDev();
    }

    /**
     * Get the webroot data
     *
     * @return string
     */
    private function getWebroot()
    {
        $extraData = $this->package->getExtra();

        return $extraData['webroot-dir'];
    }

    /**
     * Copy the index script
     *
     * @param string  $webroot Webroot
     * @param boolean $devMode Dev mode
     *
     * @return $this
     */
    private function copyIndex($webroot, $devMode = false)
    {
        $this->copyFrom($webroot, $devMode, 'index.php');

        return $this;
    }

    /**
     * Copy content folder
     *
     * @param string  $webroot Webroot
     * @param boolean $devMode Dev mode
     *
     * @return $this
     */
    private function copyContent($webroot, $devMode = false)
    {
        $this->copyFrom($webroot, $devMode, 'content');

        return $this;
    }

    /**
     * Copy assets folder
     *
     * @param string  $webroot Webroot
     * @param boolean $devMode Dev mode
     *
     * @return $this
     */
    private function copyAssets($webroot, $devMode = false)
    {
        $this->copyFrom($webroot, $devMode, 'content');

        return $this;
    }

    /**<commit_msg>Fixed assets copy from path<commit_after><?php

namespace MarkWilson\Composer;

use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Package\Package;
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Symfony\Component\Filesystem\Filesystem;

/**
 * Wordpress plugin
 *
 * @package MarkWilson\Composer
 * @author  <NAME> <<EMAIL>>
 */
class WordpressPlugin implements PluginInterface, EventSubscriberInterface
{
    /**
     * Root package
     *
     * @var Package
     */
    private $package;

    /**
     * IO
     *
     * @var IOInterface
     */
    private $io;

    /**
     * Project root
     *
     * @var string
     */
    private $projectRoot;

    /**
     * Activate Wordpress plugin
     *
     * @param Composer    $composer Composer
     * @param IOInterface $io       IO
     *
     * @return void
     */
    public function activate(Composer $composer, IOInterface $io)
    {
        $this->package = $composer->getPackage();
        $this->io = $io;

        // TODO: get the project root - must be a better way to do this
        $this->projectRoot = dirname($composer->getConfig()->get('vendor-dir'));
    }

    /**
     * Get the subscribed events
     *
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return array(
            ScriptEvents::POST_INSTALL_CMD => array(
                array('initialiseWordpress', 0)
            ),
            ScriptEvents::POST_UPDATE_CMD => array(
                array('initialiseWordpress', 0)
            ),
        );
    }

    /**
     * Initialise the project
     *
     * @param Event $event Event
     *
     * @return void
     */
    public function initialiseWordpress(Event $event)
    {
        $webroot = $this->getWebroot();
        $devMode = $this->isDevMode();

        $this->copyIndex($webroot, $devMode);
        $this->copyContent($webroot, $devMode);
        $this->copyAssets($webroot, $devMode);
    }

    /**
     * Are we in dev mode?
     *
     * @return boolean
     */
    private function isDevMode()
    {
        return $this->package->isDev();
    }

    /**
     * Get the webroot data
     *
     * @return string
     */
    private function getWebroot()
    {
        $extraData = $this->package->getExtra();

        return $extraData['webroot-dir'];
    }

    /**
     * Copy the index script
     *
     * @param string  $webroot Webroot
     * @param boolean $devMode Dev mode
     *
     * @return $this
     */
    private function copyIndex($webroot, $devMode = false)
    {
        $this->copyFrom($webroot, $devMode, 'index.php');

        return $this;
    }

    /**
     * Copy content folder
     *
     * @param string  $webroot Webroot
     * @param boolean $devMode Dev mode
     *
     * @return $this
     */
    private function copyContent($webroot, $devMode = false)
    {
        $this->copyFrom($webroot, $devMode, 'content');

        return $this;
    }

    /**
     * Copy assets folder
     *
     * @param string  $webroot Webroot
     * @param boolean $devMode Dev mode
     *
     * @return $this
     */
    private function copyAssets($webroot, $devMode = false)
    {
        $this->copyFrom($webroot, $devMode, 'assets');

        return $this;
    }

    /**
{'fraction_non_alphanumeric': 0.12501860395892245, 'fraction_numerical': 0.0005953266855186784, 'mean_word_length': 1.977403633141338, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 49, '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': '4249522', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1996, 'n_words': 458}