Passed
Push — main ( e5d18b...282b2b )
by Sugeng
03:08
created

UrlGeneratorAdapterTrait::publicUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace diecoding\flysystem\traits;
4
5
use DateTimeInterface;
6
use diecoding\flysystem\AbstractComponent;
7
use League\Flysystem\Config;
8
use yii\helpers\Json;
9
use yii\helpers\Url;
10
11
/**
12
 * Trait UrlGeneratorAdapterTrait for Adapter
13
 * 
14
 * @property AbstractComponent|UrlGeneratorComponentTrait $component
15
 * 
16
 * @link      https://sugengsulistiyawan.my.id/
17
 * @author    Sugeng Sulistiyawan <[email protected]>
18
 * @copyright Copyright (c) 2023
19
 */
20
trait UrlGeneratorAdapterTrait
21
{
22
    public function publicUrl(string $path, Config $config): string
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed. ( Ignorable by Annotation )

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

22
    public function publicUrl(string $path, /** @scrutinizer ignore-unused */ Config $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        // TODO: Use absolute path and don't encrypt
25
        $params = [
26
            'path' => $path,
27
            'expires' => 0,
28
        ];
29
30
        return Url::toRoute([$this->component->action, 'data' => $this->component->encrypt(Json::encode($params))], true);
0 ignored issues
show
Bug Best Practice introduced by
The property action does not exist on diecoding\flysystem\AbstractComponent. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method encrypt() does not exist on diecoding\flysystem\AbstractComponent. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

30
        return Url::toRoute([$this->component->action, 'data' => $this->component->/** @scrutinizer ignore-call */ encrypt(Json::encode($params))], true);
Loading history...
31
    }
32
33
    public function temporaryUrl(string $path, DateTimeInterface $expiresAt, Config $config): string
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed. ( Ignorable by Annotation )

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

33
    public function temporaryUrl(string $path, DateTimeInterface $expiresAt, /** @scrutinizer ignore-unused */ Config $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        // TODO: Use absolute path and don't encrypt
36
        $params = [
37
            'path' => $path,
38
            'expires' => (int) $expiresAt->getTimestamp(),
39
        ];
40
41
        return Url::toRoute([$this->component->action, 'data' => $this->component->encrypt(Json::encode($params))], true);
0 ignored issues
show
Bug Best Practice introduced by
The property action does not exist on diecoding\flysystem\AbstractComponent. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
    }
43
}