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.

ArrayRandValueTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_can_handle_an_empty_array() 0 4 1
A it_can_get_a_random_value() 0 7 1
A it_can_get_multiple_random_values() 0 11 2
1
<?php
2
3
namespace Spatie\Test;
4
5
use function spatie\array_rand_value;
6
use PHPUnit\Framework\TestCase;
7
8
class ArrayRandValueTest extends TestCase
9
{
10
    protected $testArray = [
11
        'one' => 'a',
12
        'two' => 'b',
13
        'three' => 'c',
14
    ];
15
16
    /**
17
     * @test
18
     */
19
    public function it_can_handle_an_empty_array()
20
    {
21
        $this->assertNull(array_rand_value([]));
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function it_can_get_a_random_value()
28
    {
29
        $testArrayValues = array_values($this->testArray);
30
        $randomArrayValue = array_rand_value($this->testArray);
31
32
        $this->assertContains($randomArrayValue, $testArrayValues);
33
    }
34
35
    /**
36
     * @test
37
     */
38
    public function it_can_get_multiple_random_values()
39
    {
40
        $testArrayValues = array_values($this->testArray);
41
        $randomArrayValues = array_rand_value($this->testArray, 2);
42
43
        $this->assertCount(2, $randomArrayValues);
44
45
        foreach ($randomArrayValues as $randomArrayValue) {
46
            $this->assertContains($randomArrayValue, $testArrayValues);
47
        }
48
    }
49
}
50