AlterTableCodeStore   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A indentationMode() 0 17 4
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