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.

BigIntegerConstructorTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 70
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmpty() 0 12 1
A testWithInteger() 0 12 1
A testWithString() 0 12 1
A testWithBigInteger() 0 13 1
A testWithInvalidValue() 0 11 1
1
<?php
2
3
namespace PHP\Math\BigIntegerTest;
4
5
use PHP\Math\BigInteger\BigInteger;
6
use PHPUnit_Framework_TestCase;
7
8
class BigIntegerConstructorTest extends PHPUnit_Framework_TestCase
9
{
10
    public function testEmpty()
11
    {
12
        // Arrange
13
        // ...
14
15
        // Act
16
        $bigInteger = new BigInteger();
17
18
        // Assert
19
        $this->assertInternalType('string', $bigInteger->getValue());
20
        $this->assertEquals('0', $bigInteger->getValue());
21
    }
22
23
    public function testWithInteger()
24
    {
25
        // Arrange
26
        // ...
27
28
        // Act
29
        $bigInteger = new BigInteger(123);
30
31
        // Assert
32
        $this->assertInternalType('string', $bigInteger->getValue());
33
        $this->assertEquals('123', $bigInteger->getValue());
34
    }
35
36
    public function testWithString()
37
    {
38
        // Arrange
39
        // ...
40
41
        // Act
42
        $bigInteger = new BigInteger('123');
43
44
        // Assert
45
        $this->assertInternalType('string', $bigInteger->getValue());
46
        $this->assertEquals('123', $bigInteger->getValue());
47
    }
48
49
    public function testWithBigInteger()
50
    {
51
        // Arrange
52
        // ...
53
54
        // Act
55
        $bigIntegerValue = new BigInteger('123');
56
        $bigInteger = new BigInteger($bigIntegerValue);
0 ignored issues
show
Documentation introduced by
$bigIntegerValue is of type object<PHP\Math\BigInteger\BigInteger>, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
57
58
        // Assert
59
        $this->assertInternalType('string', $bigInteger->getValue());
60
        $this->assertEquals('123', $bigInteger->getValue());
61
    }
62
63
    /**
64
     * @expectedException InvalidArgumentException
65
     */
66
    public function testWithInvalidValue()
67
    {
68
        // Arrange
69
        // ...
70
71
        // Act
72
        new BigInteger('123.123');
73
74
        // Assert
75
        // ...
76
    }
77
}
78