LogWrapper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 49
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDocBlockReturnType() 0 3 1
A generateMethodBodyWithLobReturnData() 0 2 1
A generateMethodBodyWithoutLob() 0 7 1
A getReturnTypeDeclaration() 0 3 1
A generateMethodBodyWithLobFetchData() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SetBased\Stratum\MySql\Wrapper;
5
6
use SetBased\Stratum\Common\Wrapper\Helper\WrapperContext;
7
use SetBased\Stratum\MySql\Exception\MySqlDataLayerException;
8
9
/**
10
 * Class for generating a wrapper method for a stored procedure 'selecting' rows for logging.
11
 */
12
class LogWrapper extends MysqlWrapper
13
{
14
  //--------------------------------------------------------------------------------------------------------------------
15
  /**
16
   * @inheritdoc
17 1
   */
18
  protected function generateMethodBodyWithLobFetchData(WrapperContext $context): void
19 1
  {
20
    // Nothing to do.
21
  }
22
23
  //--------------------------------------------------------------------------------------------------------------------
24
  /**
25
   * @inheritdoc
26 1
   */
27
  protected function generateMethodBodyWithLobReturnData(WrapperContext $context): void
28 1
  {
29
    // Nothing to do.
30
  }
31
32
  //--------------------------------------------------------------------------------------------------------------------
33
  /**
34
   * @inheritdoc
35 1
   */
36
  protected function generateMethodBodyWithoutLob(WrapperContext $context): void
37 1
  {
38
    $this->throws(MySqlDataLayerException::class);
39 1
40 1
    $context->codeStore->append(sprintf("return \$this->executeLog('call %s(%s)');",
41
                                        $context->phpStratumMetadata['routine_name'],
42
                                        $this->getRoutineArgs($context)));
43
  }
44
45
  //--------------------------------------------------------------------------------------------------------------------
46
  /**
47
   * @inheritdoc
48
   */
49
  protected function getDocBlockReturnType(WrapperContext $context): string
50
  {
51
    return 'int';
52
  }
53
54
  //--------------------------------------------------------------------------------------------------------------------
55
  /**
56
   * @inheritdoc
57
   */
58
  protected function getReturnTypeDeclaration(WrapperContext $context): string
59
  {
60
    return ': int';
61
  }
62
63
  //--------------------------------------------------------------------------------------------------------------------
64
}
65
66
//----------------------------------------------------------------------------------------------------------------------
67