Completed
Push — master ( 75298d...3aa483 )
by
unknown
02:10
created

InvalidColumnName::invalidCharacters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\QueryBuilder\Exceptions;
4
5
use Illuminate\Http\Response;
6
7
class InvalidColumnName extends InvalidQuery
8
{
9
    /** @var string */
10
    public $column;
11
12
    public function __construct(string $column, string $message)
13
    {
14
        $this->column = $column;
15
16
        parent::__construct(Response::HTTP_BAD_REQUEST, $message);
17
    }
18
19
    public static function columnNameTooLong(string $column, int $maxLength = 64)
20
    {
21
        return new static($column, "Given column name `{$column}` exceeds the maximum column name length of {$maxLength} characters.");
22
    }
23
24
    public static function invalidCharacters(string $column)
25
    {
26
        return new static($column, 'Column name may contain only alphanumerics or underscores, and may not begin with a digit.');
27
    }
28
}
29