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.

it_can_handle_an_empty_array()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Test;
4
5
use function spatie\array_rand_weighted;
6
use PHPUnit\Framework\TestCase;
7
8
class ArrayRandWeightedTest extends TestCase
9
{
10
    protected $testArray = [
11
        'foo' => 1,
12
        'bar' => 1,
13
        'baz' => 4,
14
    ];
15
16
    /**
17
     * @test
18
     */
19
    public function it_can_handle_an_empty_array()
20
    {
21
        $this->assertNull(array_rand_weighted([]));
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function it_retrieves_a_value_from_the_array()
28
    {
29
        $this->assertContains(array_rand_weighted($this->testArray), array_keys($this->testArray));
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function it_is_safe_to_assume_the_result_is_weighted()
36
    {
37
        $results = [];
38
39
        for ($i = 0; $i < 100; ++$i) {
40
            $results[] = array_rand_weighted($this->testArray);
41
        }
42
43
        $resultCounts = array_count_values($results);
44
45
        $this->assertGreaterThan($resultCounts['foo'] + $resultCounts['bar'], $resultCounts['baz']);
46
    }
47
}
48