twistor/flysystem-passthrough-adapter

A simple adapter that wraps another adapter.

v1.0.0 2015-12-09 01:01 UTC

README

Author Build Status Coverage Status Quality Score Software License Packagist Version

Installation

composer require twistor/flysystem-passthrough-adapter

Usage

This package doesn't do anything on its own. It provides a base class that simplifies the creation of adapters that wrap other adapters.

To use it, subclass \Twistor\Flysystem\PassthroughAdapter and override any methods.

<?php

use League\Flysystem\AdapterInterface;
use Twistor\Flysystem\PassthroughAdapter;

class UppercaseAdapter extends PassthroughAdapter
{
    /**
     * Constructs an UppercaseAdapter.
     *
     * @param AdapterInterface $adapter
     */
    public function __construct(AdapterInterface $adapter)
    {
        parent::__construct($adapter);
    }

    /**
     * @inheritdoc
     */
    public function read($path)
    {
        $result = $this->getAdapter()->read($path);

        if ($result === false) {
            return false;
        }

        $result['contents'] = strtoupper($result['contents']);

        return $result;
    }
}