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 (#8)
by Casper
01:29
created

Watcher::useCacheFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\PhpUnitWatcher;
4
5
use Symfony\Component\Finder\Finder;
6
use Symfony\Component\Process\Process;
7
use Yosymfony\ResourceWatcher\ResourceCacheMemory;
8
use Yosymfony\ResourceWatcher\ResourceWatcher;
9
10
class Watcher
11
{
12
    /** @var \Symfony\Component\Finder\Finder */
13
    protected $finder;
14
15
    /** @var $string */
16
    protected $phpunitArguments;
17
18
    public function __construct(Finder $finder)
19
    {
20
        $this->finder = $finder;
21
    }
22
23
    public function usePhpunitArguments(string $arguments)
24
    {
25
        $this->phpunitArguments = $arguments;
26
27
        return $this;
28
    }
29
30
    public function startWatching()
31
    {
32
        $this->runTests();
33
34
        $watcher = new ResourceWatcher(new ResourceCacheMemory());
35
36
        $watcher->setFinder($this->finder);
37
38
        while (true) {
39
            $watcher->findChanges();
40
41
            if ($watcher->hasChanges()) {
42
                $this->clearScreen();
43
                $this->runTests();
44
            }
45
46
            usleep(250000);
47
        }
48
    }
49
50
    protected function clearScreen()
51
    {
52
        passthru("echo '\033\143'");
53
    }
54
55
    protected function runTests()
56
    {
57
        (new Process("vendor/bin/phpunit {$this->phpunitArguments}"))
58
            ->setTty(true)
59
            ->run(function ($type, $line) {
60
                echo $line;
61
            });
62
    }
63
}
64