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
Push — master ( 2c206f...9352c3 )
by Cees-Jan
97:45
created

TestCase::provideTrueFalse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\TestUtilities;
4
5
use PHPUnit_Framework_TestCase;
6
use RecursiveDirectoryIterator;
7
use RecursiveIteratorIterator;
8
9
abstract class TestCase extends PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var string
13
     */
14
    private $tmpDir;
15
16
    /**
17
     * @var string
18
     */
19
    private $tmpNamespace;
20
21
    public function setUp()
22
    {
23
        parent::setUp();
24
25
        $this->tmpDir = sys_get_temp_dir() .
26
            DIRECTORY_SEPARATOR .
27
            uniqid('wyrihaximus-php-api-client-tests-', true) .
28
            DIRECTORY_SEPARATOR
29
        ;
30
31
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
32
            $this->tmpDir = 'C:\\t\\';
33
        }
34
35
        mkdir($this->tmpDir, 0777, true);
36
        $this->tmpNamespace = uniqid('WHPACTN', true);
37
    }
38
39
    public function tearDown()
40
    {
41
        parent::tearDown();
42
        $this->rmdir($this->tmpDir);
43
    }
44
45
    protected function rmdir($dir)
46
    {
47
        $directory = dir($dir);
48
        while (false !== ($entry = $directory->read())) {
49
            if (in_array($entry, ['.', '..'])) {
50
                continue;
51
            }
52
53
            if (is_dir($dir . $entry)) {
54
                $this->rmdir($dir . $entry . DIRECTORY_SEPARATOR);
55
                continue;
56
            }
57
58
            if (is_file($dir . $entry)) {
59
                unlink($dir . $entry);
60
                continue;
61
            }
62
        }
63
        $directory->close();
64
        rmdir($dir);
65
    }
66
67
    protected function getTmpDir(): string
68
    {
69
        return $this->tmpDir;
70
    }
71
72
    protected function getRandomNameSpace(): string
73
    {
74
        return $this->tmpNamespace;
75
    }
76
77
    protected function getFilesInDirectory(string $path): array
78
    {
79
        $files = [];
80
81
        $directory = new RecursiveDirectoryIterator($path);
82
        $directory = new RecursiveIteratorIterator($directory);
83
84
        foreach ($directory as $node) {
85
            if (!is_file($node->getPathname())) {
86
                continue;
87
            }
88
89
            $files[] = $node->getPathname();
90
        }
91
92
        return $files;
93
    }
94
95
    public function provideTrueFalse(): array
96
    {
97
        return [
98
            [
99
                true,
100
            ],
101
            [
102
                false,
103
            ],
104
        ];
105
    }
106
}
107