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

plank / laravel-mediable / 13689748990

06 Mar 2025 02:19AM UTC coverage: 94.72%. Remained the same
13689748990

push

github

web-flow
Fix template type definition in MediableCollection (#378)

1489 of 1572 relevant lines covered (94.72%)

153.81 hits per line

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

92.31
/src/SourceAdapters/LocalPathAdapter.php
1
<?php
2
declare(strict_types=1);
3

4
namespace Plank\Mediable\SourceAdapters;
5

6
use GuzzleHttp\Psr7\Utils;
7
use Plank\Mediable\Exceptions\MediaUpload\ConfigurationException;
8
use Plank\Mediable\Exceptions\MediaUpload\FileNotFoundException;
9
use Plank\Mediable\Helpers\File;
10
use Psr\Http\Message\StreamInterface;
11

12
/**
13
 * Local Path Adapter.
14
 *
15
 * Adapts a string representing an absolute path
16
 */
17
class LocalPathAdapter extends StreamAdapter
18
{
19
    protected string $filePath;
20

21
    public function __construct(string $source)
22
    {
23
        $this->filePath = $source;
96✔
24
        if (!is_file($source) || !is_readable($source)) {
96✔
25
            throw ConfigurationException::invalidSource(
6✔
26
                "File not found {$source}"
6✔
27
            );
6✔
28
        }
29
        parent::__construct(
90✔
30
            Utils::streamFor(Utils::tryFopen($source, 'rb'))
90✔
31
        );
90✔
32
    }
33

34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function path(): ?string
38
    {
39
        return $this->filePath;
×
40
    }
41

42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function filename(): ?string
46
    {
47
        return pathinfo($this->filePath, PATHINFO_FILENAME) ?: null;
24✔
48
    }
49

50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function extension(): ?string
54
    {
55
        return pathinfo($this->filePath, PATHINFO_EXTENSION) ?: null;
90✔
56
    }
57

58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function mimeType(): string
62
    {
63
        return mime_content_type($this->filePath);
90✔
64
    }
65

66
    public function clientMimeType(): ?string
67
    {
68
        return null;
6✔
69
    }
70
}
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

© 2025 Coveralls, Inc