Issues (45)

src/Commands/Handlers/GetBucketPolicy.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 *  This file is part of the Simple S3 package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
namespace Matecat\SimpleS3\Commands\Handlers;
13
14
use Matecat\SimpleS3\Commands\CommandHandler;
15
16
class GetBucketPolicy extends CommandHandler
17
{
18
    /**
19
     * Get the policy of a bucket.
20
     *
21
     * @param array $params
22
     *
23
     * @return int|mixed
24
     * @throws \Exception
25
     */
26
    public function handle($params = [])
27
    {
28
        $bucketName = $params['bucket'];
29
30
        $result = $this->client->getConn()->getBucketPolicy([
31
            'Bucket' => $bucketName,
32
        ]);
33
34
        if (null !== $this->commandHandlerLogger) {
35
            $this->commandHandlerLogger->log($this, sprintf('Size of \'%s\' bucket was successfully obtained', $bucketName));
36
        }
37
38
        return (isset($result['Policy'])) ? json_decode($result['Policy']->getContents(), true) : '';
0 ignored issues
show
The method getContents() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        return (isset($result['Policy'])) ? json_decode($result['Policy']->/** @scrutinizer ignore-call */ getContents(), true) : '';

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
    }
40
41
    /**
42
     * @param array $params
43
     *
44
     * @return bool
45
     */
46
    public function validateParams($params = [])
47
    {
48
        return isset($params['bucket']);
49
    }
50
}
51