public static function attach(
        HasEmitterInterface $subject,
        array $options = []
    ) {
        if (!isset($options['storage'])) {
            $options['storage'] = new CacheStorage(new ArrayCache());
        }

        if (!isset($options['can_cache'])) {
            $options['can_cache'] = [
                'GuzzleHttp\Subscriber\Cache\Utils',
                'canCacheRequest',
            ];
        }

        $emitter = $subject->getEmitter();
        $cache = new self($options['storage'], $options['can_cache']);
        $emitter->attach($cache);

        if (!isset($options['validate']) || $options['validate'] === true) {
            $emitter->attach(new ValidationSubscriber(
                $options['storage'],
                $options['can_cache'])
            );
        }

        if (!isset($options['purge']) || $options['purge'] === true) {
            $emitter->attach(new PurgeSubscriber($options['storage']));
        }

        return ['subscriber' => $cache, 'storage' => $options['storage']];
    }