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

laravie / stream / 4298476058

pending completion
4298476058

push

github

GitHub
wip

25 of 28 relevant lines covered (89.29%)

1.57 hits per line

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

81.25
/src/Laravel/StreamServiceProvider.php
1
<?php
2

3
namespace Laravie\Stream\Laravel;
4

5
use Illuminate\Support\ServiceProvider;
6
use React\EventLoop\Factory;
7
use React\EventLoop\LoopInterface;
8
use React\Stream\ThroughStream;
9
use React\Stream\WritableResourceStream;
10
use React\Stream\WritableStreamInterface;
11

12
class StreamServiceProvider extends ServiceProvider
13
{
14
    /**
15
     * Register the application services.
16
     *
17
     * @return void
18
     */
19
    public function register()
20
    {
21
        $this->app->bind(LoopInterface::class, static function () {
1✔
22
            return Factory::create();
1✔
23
        });
1✔
24

25
        $this->app->bind(WritableStreamInterface::class, function () {
1✔
26
            return $this->createOutputStream();
1✔
27
        });
1✔
28
    }
29

30
    /**
31
     * Get an output stream.
32
     */
33
    protected function createOutputStream(): WritableStreamInterface
34
    {
35
        if (\defined('STDOUT') && DIRECTORY_SEPARATOR === '/') {
1✔
36
            return new WritableResourceStream(STDOUT, app(LoopInterface::class));
1✔
37
        }
38

39
        return new ThroughStream(static function ($data) {
×
40
            echo "{$data}\n";
×
41
        });
×
42
    }
43

44
    /**
45
     * Get the services provided by the provider.
46
     *
47
     * @return array<int, class-string>
48
     */
49
    public function provides()
50
    {
51
        return [
1✔
52
            LoopInterface::class,
1✔
53
            WritableStreamInterface::class,
1✔
54
        ];
1✔
55
    }
56

57
    /**
58
     * Determine if the provider is deferred.
59
     *
60
     * @return bool
61
     */
62
    public function isDeferred()
63
    {
64
        return true;
1✔
65
    }
66
}
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