twistor/flysystem-passthrough-adapter

一个简单的适配器,用于包装另一个适配器。

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

This package is auto-updated.

Last update: 2024-08-26 10:15:33 UTC


README

Author Build Status Coverage Status Quality Score Software License Packagist Version

安装

composer require twistor/flysystem-passthrough-adapter

使用

此包本身不执行任何操作。它提供了一个基类,简化了包装其他适配器的适配器的创建。

要使用它,请继承 \Twistor\Flysystem\PassthroughAdapter 并重写任何方法。

<?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;
    }
}