GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#23)
by
unknown
03:34
created

Watcher   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 7
dl 0
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A usePhpunitArguments() 0 6 1
A setNotifications() 0 3 1
A startWatching() 0 22 3
1
<?php
2
3
namespace Spatie\PhpUnitWatcher;
4
5
use Clue\React\Stdio\Stdio;
6
use React\EventLoop\Factory;
7
use Symfony\Component\Finder\Finder;
8
use Spatie\PhpUnitWatcher\Screens\Phpunit;
9
use Yosymfony\ResourceWatcher\ResourceWatcher;
10
use Yosymfony\ResourceWatcher\ResourceCacheMemory;
11
12
class Watcher
13
{
14
    /** @var \Symfony\Component\Finder\Finder */
15
    protected $finder;
16
17
    /** @var $string */
18
    protected $phpunitArguments;
19
20
    /** @var bool */
21
    protected $notifications;
22
23
    /** @var \React\EventLoop\LibEventLoop */
24
    protected $loop;
25
26
    /** @var \Spatie\PhpUnitWatcher\Terminal */
27
    protected $terminal;
28
29
    public function __construct(Finder $finder)
30
    {
31
        $this->finder = $finder;
32
33
        $this->loop = Factory::create();
34
35
        $this->terminal = new Terminal(new Stdio($this->loop));
36
    }
37
38
    public function usePhpunitArguments(string $arguments)
39
    {
40
        $this->phpunitArguments = $arguments;
41
42
        return $this;
43
    }
44
45
    public function setNotifications(bool $status) {
46
        $this->notifications = $status;
47
    }
48
49
    public function startWatching()
50
    {
51
        $this->terminal->displayScreen(new Phpunit($this->phpunitArguments, $this->notifications), false);
52
53
        $watcher = new ResourceWatcher(new ResourceCacheMemory());
54
55
        $watcher->setFinder($this->finder);
56
57
        $this->loop->addPeriodicTimer(1 / 4, function () use ($watcher) {
58
            if (! $this->terminal->isDisplayingScreen(Phpunit::class)) {
59
                return;
60
            }
61
62
            $watcher->findChanges();
63
64
            if ($watcher->hasChanges()) {
65
                $this->terminal->refreshScreen();
66
            }
67
        });
68
69
        $this->loop->run();
70
    }
71
}
72