• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / plugin / 7322930040

25 Dec 2023 04:02PM UTC coverage: 37.918% (-1.7%) from 39.661%
7322930040

push

github

twinh
ci: add PHP 8, remove PHP 7.2, 7.3

907 of 2392 relevant lines covered (37.92%)

5.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Service/Storage.php
1
<?php
2

3
namespace Miaoxing\Plugin\Service;
4

5
use Wei\Ret;
6

7
class Storage extends BaseStorage
8
{
9
    /**
10
     * The file service object
11
     *
12
     * @var BaseStorage|null
13
     */
14
    protected $object;
15

16
    /**
17
     * The storage service driver
18
     *
19
     * @var string
20
     */
21
    protected $driver = 'localStorage';
22

23
    /**
24
     * Constructor
25
     */
26
    public function __construct(array $options = [])
27
    {
28
        parent::__construct($options);
×
29

30
        if (!$this->object) {
×
31
            $this->setDriver($this->driver);
×
32
        }
33
    }
34

35
    /**
36
     * {@inheritdoc}
37
     * @svc
38
     */
39
    protected function write(string $path, string $content, array $options = []): Ret
40
    {
41
        return $this->object->write($path, $content, $options);
×
42
    }
43

44
    /**
45
     * {@inheritdoc}
46
     * @svc
47
     */
48
    protected function moveLocal(string $path, array $options = []): Ret
49
    {
50
        return $this->object->moveLocal($path, $options);
×
51
    }
52

53
    /**
54
     * {@inheritdoc}
55
     * @svc
56
     */
57
    protected function getUrl(string $path): string
58
    {
59
        return $this->object->getUrl($path);
×
60
    }
61

62
    /**
63
     * Get the file driver
64
     *
65
     * @svc
66
     */
67
    protected function getDriver(): string
68
    {
69
        return $this->driver;
×
70
    }
71

72
    /**
73
     * Set file driver
74
     *
75
     * @svc
76
     */
77
    protected function setDriver(string $driver): self
78
    {
79
        $class = $this->wei->getClass($driver);
×
80

81
        if (!class_exists($class)) {
×
82
            throw new \InvalidArgumentException(sprintf('Storage driver class "%s" not found', $class));
×
83
        }
84

85
        $object = $this->wei->get($driver);
×
86
        if (!$object instanceof BaseStorage) {
×
87
            throw new \InvalidArgumentException(sprintf(
×
88
                'Storage driver object "%s" must extend "BaseStorage"',
×
89
                $class
×
90
            ));
×
91
        }
92

93
        $this->driver = $driver;
×
94
        $this->object = $object;
×
95
        return $this;
×
96
    }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc