• 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

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
    {
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

© 2025 Coveralls, Inc