Test Failed
Push — master ( 0d5d14...c17ef6 )
by SuperNova.WS
06:37
created

DbIndexField   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 11

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 3
B fromMySqlDescription() 0 10 8
1
<?php
2
/**
3
 * Created by Gorlum 01.03.2019 9:06
4
 */
5
6
namespace DBAL;
7
8
class DbIndexField {
9
  public $Column_name; // Column_name - The column name. See also the description for the Expression column.
10
  public $Seq_in_index; // The column sequence number in the index, starting with 1.
11
  public $Collation; // How the column is sorted in the index. This can have values A (ascending), D (descending), or NULL (not sorted).
12
  public $Cardinality; // An estimate of the number of unique values in the index. To update this number, run ANALYZE TABLE or (for MyISAM tables) myisamchk -a.
13
  public $Sub_part; // The index prefix. That is, the number of indexed characters if the column is only partly indexed, NULL if the entire column is indexed.
14
  public $Null; // Contains YES if the column may contain NULL values and '' if not.
15
  public $Expression; // MySQL 8.0.13 and higher supports functional key parts (see Functional Key Parts), which affects both the Column_name and Expression columns:
16
17
  public function __construct($indexField = []) {
18
    is_array($indexField) && !empty($indexField) ? $this->fromMySqlDescription($indexField) : false;
19
  }
20
21
  /**
22
   * @param array $indexField
23
   */
24
  public function fromMySqlDescription($indexField) {
25
    $this->Seq_in_index = isset($indexField['Seq_in_index']) ? $indexField['Seq_in_index'] : null;
26
    $this->Column_name  = isset($indexField['Column_name']) ? $indexField['Column_name'] : null;
27
    $this->Collation    = isset($indexField['Collation']) ? $indexField['Collation'] : null;
28
    $this->Cardinality  = isset($indexField['Cardinality']) ? $indexField['Cardinality'] : null;
29
    $this->Sub_part     = isset($indexField['Sub_part']) ? $indexField['Sub_part'] : null;
30
    $this->Null         = isset($indexField['Null']) ? $indexField['Null'] : null;
31
    $this->Expression   = isset($indexField['Expression']) ? $indexField['Expression'] : null;
32
33
    return $this;
34
  }
35
36
}
37