<commit_before><?php declare(strict_types=1);
/* (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Host;

use Deployer\Configuration\Configuration;
use Deployer\Deployer;
use Deployer\Task\Context;

class Host
{
    /**
     * @var Configuration $config
     */
    private $config;

    public function __construct(string $hostname)
    {
        $parent = null;
        if (Deployer::get()) {
            $parent = Deployer::get()->config;
        }
        $this->config = new Configuration($parent);
        $this->set('alias', $hostname);
        $this->set('hostname', preg_replace('/\/.+$/', '', $hostname));
    }

    public function __toString(): string
    {
        $asterisks = '';
        if (Context::has() && Context::get()->isLocal()) {
            $asterisks = '*';
        }
        return "$asterisks{$this->getTag()}";
    }

    public function config(): Configuration
    {
        return $this->config;
    }

    /**
     * @param mixed $value
     */
    public function set(string $name, $value): self
    {
        $this->config->set($name, $value);
        return $this;
    }
<commit_msg>Disallow alias changing<commit_after><?php declare(strict_types=1);
/* (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Host;

use Deployer\Configuration\Configuration;
use Deployer\Deployer;
use Deployer\Exception\ConfigurationException;
use Deployer\Task\Context;

class Host
{
    /**
     * @var Configuration $config
     */
    private $config;

    public function __construct(string $hostname)
    {
        $parent = null;
        if (Deployer::get()) {
            $parent = Deployer::get()->config;
        }
        $this->config = new Configuration($parent);
        $this->set('#alias', $hostname);
        $this->set('hostname', preg_replace('/\/.+$/', '', $hostname));
    }

    public function __toString(): string
    {
        $asterisks = '';
        if (Context::has() && Context::get()->isLocal()) {
            $asterisks = '*';
        }
        return "$asterisks{$this->getTag()}";
    }

    public function config(): Configuration
    {
        return $this->config;
    }

    /**
     * @param mixed $value
     */
    public function set(string $name, $value): self
    {
        if ($name === 'alias') {
            throw new ConfigurationException("Can not update alias of the host.\nThis will change only host own alias,\nbut not the key it is stored in HostCollection.");
        }
        if ($name === '#alias') {
            $name = 'alias';
        }
        $this->config->set($name, $value);
        return $this;
    }

{'fraction_non_alphanumeric': 0.15400918403391028, 'fraction_numerical': 0.0007064641469445425, 'mean_word_length': 2.3835125448028673, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '6768824', 'n_tokens_mistral': 821, 'n_tokens_neox': 814, 'n_words': 209}