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

plank / laravel-mediable / 8585433686

07 Apr 2024 02:04AM UTC coverage: 95.282% (-0.5%) from 95.789%
8585433686

push

github

web-flow
Merge pull request #343 from plank/v6

V6

338 of 375 new or added lines in 30 files covered. (90.13%)

1 existing line in 1 file now uncovered.

1434 of 1505 relevant lines covered (95.28%)

117.76 hits per line

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

95.0
/src/SourceAdapters/RemoteUrlAdapter.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

9
/**
10
 * URL Adapter.
11
 *
12
 * Adapts a string representing a URL
13
 */
14
class RemoteUrlAdapter extends StreamAdapter
15
{
16
    protected string $url;
17

18
    public function __construct(string $source)
19
    {
20
        $this->url = $source;
18✔
21
        try {
22
            $resource = Utils::tryFopen($source, 'rb');
18✔
23
            $stream = Utils::streamFor($resource);
6✔
24
        } catch (\RuntimeException $e) {
12✔
25
            throw ConfigurationException::invalidSource(
12✔
26
                "Failed to connect to URL: {$e->getMessage()}",
12✔
27
                $e
12✔
28
            );
12✔
29
        }
30
        parent::__construct(
6✔
31
            $stream
6✔
32
        );
6✔
33
    }
34

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

43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function filename(): ?string
47
    {
48
        return pathinfo(
6✔
49
            parse_url($this->url, PHP_URL_PATH),
6✔
50
            PATHINFO_FILENAME
6✔
51
        ) ?: null;
6✔
52
    }
53

54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function extension(): ?string
58
    {
59
        return pathinfo(
6✔
60
            parse_url($this->url, PHP_URL_PATH),
6✔
61
            PATHINFO_EXTENSION
6✔
62
        ) ?: null;
6✔
63
    }
64
}
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