Completed
Push — master ( 869d3d...24f8ca )
by ignace nyamagana
03:44
created

CannotBindHeader::createFromHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
* This file is part of the League.csv library
4
*
5
* @license http://opensource.org/licenses/MIT
6
* @link https://github.com/thephpleague/csv/
7
* @version 9.0.0
8
* @package League.csv
9
*
10
* For the full copyright and license information, please view the LICENSE
11
* file that was distributed with this source code.
12
*/
13
declare(strict_types=1);
14
15
namespace League\Csv\Exception;
16
17
use League\Csv\Exception;
18
use RuntimeException;
19
20
/**
21
 * Thrown if an error which can onlyu be found on runtime occurs.
22
 *
23
 * @package League.csv
24
 * @since   9.0.0
25
 * @author  Ignace Nyamagana Butera <[email protected]>
26
 *
27
 */
28
class CannotBindHeader extends RuntimeException implements Exception
29
{
30
    /**
31
     * The header submitted for binding
32
     *
33
     * @var array
34
     */
35
    protected $header;
36
37
    /**
38
     * Create an Exception from a record insertion into a stream
39
     *
40
     * @param string[] $record
0 ignored issues
show
Bug introduced by
There is no parameter named $record. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
41
     * @param array    $header
42
     *
43
     * @return self
44
     */
45 2
    public static function createFromHeader(array $header): self
46
    {
47 2
        $exception = new static('The header record must be empty or a flat array with unique string values');
48 2
        $exception->header = $header;
49
50 2
        return $exception;
51
    }
52
53
    /**
54
     * return the invalid header submitted
55
     *
56
     * @return array
57
     */
58 2
    public function getHeader(): array
59
    {
60 2
        return $this->header;
61
    }
62
}
63