Completed
Push — master ( efd012...704f4c )
by P.R.
03:36
created

MySqlAlterTableCodeStore::indentationMode()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 9.2
cc 4
eloc 8
nc 4
nop 1
crap 4
1
<?php
2
3
namespace SetBased\Audit\MySql\Helper;
4
5
use SetBased\Helper\CodeStore\CodeStore;
6
7
/**
8
 * A helper class for automatically generating MySQL alter table syntax code with proper indentation.
9
 */
10
class MySqlAlterTableCodeStore extends CodeStore
11
{
12
  //--------------------------------------------------------------------------------------------------------------------
13
  /**
14
   * @inheritdoc
15
   */
16 8
  protected function indentationMode($line)
17
  {
18 8
    $mode = 0;
19
20 8
    $line = trim($line);
21
22 8
    if (substr($line, 0, 11)=='alter table' && substr($line, -1)<>';')
23
    {
24 5
      $mode |= self::C_INDENT_INCREMENT_AFTER;
25
    }
26
27 8
    if (substr($line, 0, 1)==';')
28
    {
29 5
      $mode |= self::C_INDENT_DECREMENT_BEFORE;
30
    }
31
32 8
    return $mode;
33
  }
34
35
  //--------------------------------------------------------------------------------------------------------------------
36
}
37
38
//----------------------------------------------------------------------------------------------------------------------
39