AlterTableCodeStore::indentationMode()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

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