<commit_before><?php

namespace League\Flysystem\Adapter;

use LogicException;
use League\Flysystem\AdapterInterface;

abstract class AbstractAdapter implements AdapterInterface
{
    /**
     * Write using a stream
     *
     * @param   string  $path
     * @param   resource  $resource
     * @param   mixed     $config
     * @return  mixed     false or file metadata
     */
    public function writeStream($path, $resource, $config = null)
    {
        return $this->stream($path, $resource, $config, 'write');
    }

    /**
     * Update a file using a stream
     *<commit_msg>Implemented abstract prefixing methods<commit_after><?php

namespace League\Flysystem\Adapter;

use LogicException;
use League\Flysystem\AdapterInterface;

abstract class AbstractAdapter implements AdapterInterface
{
    /**
     * @var  string  $prefix  path prefix
     */
    protected $pathPrefix;

    /**
     * Set the path prefix
     *
     * @param   string  $prefix
     * @return  self
     */
    public function setPathPrefix($prefix)
    {
        $is_empty = empty($prefix);

        if ( ! $is_empty) {
            $prefix = rtrim($prefix, '/') . '/';
        }

        $this->pathPrefix = $is_empty ? null : $prefix;
    }

    /**
     * Prefix a path
     *
     * @param   string  $path
     * @return  string  prefixed path
     */
    public function applyPathPrefix($path)
    {
        if (empty($path)) {
            return $pathPrefix ?: '';
        }

        if ($this->pathPrefix) {
            $path = $this->pathPrefix . $path;
        }

        return $path;
    }

    /**
     * Remove a path prefix
     *
     * @param   string  $path
     * @return  string  path without the prefix
     */
    public function removePathPrefix($path)
    {
        if ($this->pathPrefix === null) {
            return $path;
        }

        $length = strlen($this->pathPrefix);

        return substr($path, $length);
    }

    /**
     * Write using a stream
     *
     * @param   string  $path
     * @param   resource  $resource
     * @param   mixed     $config
     * @return  mixed     false or file metadata
     */
    public function writeStream($path, $resource, $config = null)
    {
        return $this->stream($path, $resource, $config, 'write');
    }

    /**
     * Update a file using a stream
     *
{'fraction_non_alphanumeric': 0.11658808401200171, 'fraction_numerical': 0.0, 'mean_word_length': 1.9211514392991238, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '3807288', 'n_tokens_mistral': 685, 'n_tokens_neox': 668, 'n_words': 178}