<commit_before><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */
namespace Vision\Http;

/**
 * Url
 *
 * @author <NAME>
 */
class Url
{
    /** @type array $components */
    protected $components = array();

    /**
     * Constructor
     *
     * @param string $url
     */
    public function __construct($url)
    {
        $components = parse_url($url);

        if (!empty($components)) {
            $this->components = $components;
        }
    }

    /**
     * @api
     *
     * @param RequestInterface $request
     *
     * @return $this Provides a fluent interface.
     */
    public function populateFromRequest(RequestInterface $request)
    {
        if (!isset($this->components['scheme'])) {
            $this->components['scheme'] = $request->getScheme();
        }

        if (!isset($this->components['host'])) {
            $this->components['host'] = $request->getHost();
        }

        $path = $request->getBasePath();

        if (!isset($this->components['path']) && isset($path)) {
            $this->components['path'] = $path;
        } else {
            if (strpos($this->components['path'], '/') !== 0) {
                $this->components['path'] = '/' . $this->components['path'];
            }
            $this->components['path'] = $path . $this->components['path'];
        }

        return $this;
    }

    /**
     * @api
     *
     * @return bool|string
     */
    public function build()
    {
        $url = '';

        if (isset($this->components['scheme'])) {
            $url .= $this->components['scheme'] . '://';
        } else {
            return false;
        }

        if (isset($this->components['host'])) {
            $url .= $this->components['host'];
        } else {
            return false;
        }

        if (isset($this->components['path'])) {
            $path = $this->components['path'];
            if (strpos($path, '/') !== 0) {
                $path = '/' . $path;
            }
            $url .= $path;
        }

        if (isset($host, $this->components['query'])) {
            $url .= '?' . $this->components['query'];
        }

        if (isset($host, $this->components['fragment'])) {
            $url .= '#' . $this->components['fragment'];
        }

        return $url;
    }
}
<commit_msg>Fix: variable name<commit_after><?php
/**
 * Vision PHP-Framework
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2012-2013 <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 */
namespace Vision\Http;

/**
 * Url
 *
 * @author <NAME>
 */
class Url
{
    /** @type array $components */
    protected $components = array();

    /**
     * Constructor
     *
     * @param string $url
     */
    public function __construct($url)
    {
        $components = parse_url($url);

        if (!empty($components)) {
            $this->components = $components;
        }
    }

    /**
     * @api
     *
     * @param RequestInterface $request
     *
     * @return $this Provides a fluent interface.
     */
    public function populateFromRequest(RequestInterface $request)
    {
        if (!isset($this->components['scheme'])) {
            $this->components['scheme'] = $request->getScheme();
        }

        if (!isset($this->components['host'])) {
            $this->components['host'] = $request->getHost();
        }

        $path = $request->getBasePath();

        if (!isset($this->components['path']) && isset($path)) {
            $this->components['path'] = $path;
        } else {
            if (strpos($this->components['path'], '/') !== 0) {
                $this->components['path'] = '/' . $this->components['path'];
            }
            $this->components['path'] = $path . $this->components['path'];
        }

        return $this;
    }

    /**
     * @api
     *
     * @return bool|string
     */
    public function build()
    {
        $url = '';

        if (isset($this->components['scheme'])) {
            $url .= $this->components['scheme'] . '://';
        } else {
            return false;
        }

        if (isset($this->components['host'])) {
            $url .= $this->components['host'];
        } else {
            return false;
        }

        if (isset($this->components['path'])) {
            $path = $this->components['path'];
            if (strpos($path, '/') !== 0) {
                $path = '/' . $path;
            }
            $url .= $path;
        }

        if (isset($this->components['host'], $this->components['query'])) {
            $url .= '?' . $this->components['query'];
        }

        if (isset($this->components['host'], $this->components['fragment'])) {
            $url .= '#' . $this->components['fragment'];
        }

        return $url;
    }
}

{'fraction_non_alphanumeric': 0.19441593102032437, 'fraction_numerical': 0.0041059330732909054, 'mean_word_length': 1.747884940778342, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2724194', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1383, 'n_words': 246}