• 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

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

4
namespace Plank\Mediable\SourceAdapters;
5

6
use GuzzleHttp\Psr7\Utils;
7
use Psr\Http\Message\StreamInterface;
8

9
/**
10
 * Raw content Adapter.
11
 *
12
 * Adapts a string representing raw contents.
13
 */
14
class RawContentAdapter implements SourceAdapterInterface
15
{
16
    protected string $source;
17

18
    public function __construct(string $source)
19
    {
20
        $this->source = $source;
12✔
21
    }
22

23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function path(): ?string
27
    {
NEW
28
        return null;
×
29
    }
30

31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function filename(): ?string
35
    {
36
        return null;
6✔
37
    }
38

39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function extension(): ?string
43
    {
44
        return null;
12✔
45
    }
46

47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function mimeType(): string
51
    {
52
        $fileInfo = new \finfo(FILEINFO_MIME_TYPE);
12✔
53

54
        return (string)$fileInfo->buffer($this->source);
12✔
55
    }
56

57
    public function clientMimeType(): ?string
58
    {
59
        return null;
6✔
60
    }
61

62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function getStream(): StreamInterface
66
    {
67
        return Utils::streamFor($this->source);
12✔
68
    }
69

70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function size(): int
74
    {
75
        return mb_strlen($this->source, '8bit') ?: 0;
12✔
76
    }
77

78
    public function hash(string $algo = 'md5'): string
79
    {
80
        $hash = hash_init($algo);
6✔
81
        hash_update($hash, $this->source);
6✔
82
        return hash_final($hash);
6✔
83
    }
84
}
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