<commit_before><?php

/*
 * This file is part of Zippy.
 *
 * (c) Alchemy <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Alchemy\Zippy\Resource;

/**
 * This class represents a resource on a local filesystem
 */
class Resource
{
    /**
     * A path to a folder as the context
     *
     * @var String
     */
    private $context;

    /**
     * A resource relative path according to the context
     * @var String
     */
    private $relativepath;

    public function __constuct($workingDirectory, $relativepath)
    {
        $this->context = $workingDirectory;
        $this->relativepath = $relativepath;
    }

    public function getContext()
    {
        return $this->context;
    }

    public function setContext($workingDirectory)
    {
        $this->context = $workingDirectory;
    }

    public function getRelativepath()
    {
        return $this->relativepath;
    }

    public function setRelativepath($relativepath)
    {
        $this->relativepath = $relativepath;
    }

    /**
     * Gets the full resource path
     *
     * @return String
     */
    public function getPath()
    {
         return sprintf('%s/%s', rtrim($this->context, '/'), $this->relativepath);
    }
}<commit_msg>A Resource objects only needs an original resource and a target in archive<commit_after><?php

/*
 * This file is part of Zippy.
 *
 * (c) Alchemy <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Alchemy\Zippy\Resource;

/**
 * This class represents a resource on a local filesystem
 */
class Resource
{
    private $original;
    private $target;

    public function __construct($original, $target)
    {
        $this->original = $original;
        $this->target = $target;
    }

    public function getTarget()
    {
        return $this->target;
    }

    public function getOriginal()
    {
        return $this->original;
    }

    /**
     * Returns wheter the resource can be processed in place given a context or not.
     *
     * For example :
     *   - /path/to/file1 can be processed to file1 in /path/to context
     *   - /path/to/subdir/file2 can be processed to subdir/file2 in /path/to context
     *
     * @param string $context
     *
     * @return Boolean
     */
    public function canBeProcessedInPlace($context)
    {
        if (!is_string($this->original)) {
            return false;
        }

        $data = parse_url($this->original);

        if (!isset($data['path'])) {
            return false;
        }

        return sprintf('%s/%s', rtrim($context, '/'), $this->target) === $data['path'];
    }
}
{'fraction_non_alphanumeric': 0.11519078473722102, 'fraction_numerical': 0.0014398848092152627, 'mean_word_length': 2.284869976359338, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, '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': '7136291', 'n_tokens_mistral': 800, 'n_tokens_neox': 778, 'n_words': 241}