private function ensureBucketExists()
    {
        if ($this->ensureBucket) {
            return;
        }

        if (isset($this->options['region'])) {
            $this->service->set_region($this->options['region']);
        }

        if ($this->service->if_bucket_exists($this->bucket)) {
            $this->ensureBucket = true;

            return;
        }

        if (!$this->options['create']) {
            throw new \RuntimeException(sprintf(
                'The configured bucket "%s" does not exist.',
                $this->bucket
            ));
        }

        $response = $this->service->create_bucket(
            $this->bucket,
            $this->options['region']
        );

        if (!$response->isOK()) {
            throw new \RuntimeException(sprintf(
                'Failed to create the configured bucket "%s".',
                $this->bucket
            ));
        }

        $this->ensureBucket = true;
    }
private function ensureBucketExists()
    {
        if ($this->ensureBucket) {
            return;
        }

        if (isset($this->options['region'])) {
            $this->service->set_region($this->options['region']);
        }

        if ($this->service->if_bucket_exists($this->bucket)) {
            $this->ensureBucket = true;

            return;
        }

        if (!$this->options['create']) {
            throw new \RuntimeException(sprintf(
                'The configured bucket "%s" does not exist.',
                $this->bucket
            ));
        }

        $response = $this->service->create_bucket(
            $this->bucket,
            $this->options['region']
        );

        if (!$response->isOK()) {
            throw new \RuntimeException(sprintf(
                'Failed to create the configured bucket "%s".',
                $this->bucket
            ));
        }

        $this->ensureBucket = true;
    }
private function ensureBucketExists ( ) { if ( $ this -> ensureBucket ) { return ; } if ( isset ( $ this -> options [ 'region' ] ) ) { $ this -> service -> set_region ( $ this -> options [ 'region' ] ) ; } if ( $ this -> service -> if_bucket_exists ( $ this -> bucket ) ) { $ this -> ensureBucket = true ; return ; } if ( ! $ this -> options [ 'create' ] ) { throw new \ RuntimeException ( sprintf ( 'The configured bucket "%s" does not exist.' , $ this -> bucket ) ) ; } $ response = $ this -> service -> create_bucket ( $ this -> bucket , $ this -> options [ 'region' ] ) ; if ( ! $ response -> isOK ( ) ) { throw new \ RuntimeException ( sprintf ( 'Failed to create the configured bucket "%s".' , $ this -> bucket ) ) ; } $ this -> ensureBucket = true ; }
Ensures the specified bucket exists. If the bucket does not exists
and the create parameter is set to true, it will try to create the
bucket.

@throws \RuntimeException if the bucket does not exists or could not be
created
Ensures the specified bucket exists . If the bucket does not exists and the create parameter is set to true it will try to create the bucket .