BulkWrapper   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 65
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A generateMethodBodyWithoutLob() 0 7 1
A getDocBlockReturnType() 0 3 1
A getReturnTypeDeclaration() 0 3 1
A enhancePhpDocBlockParameters() 0 10 1
A generateMethodBodyWithLobReturnData() 0 2 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\Middle\BulkHandler;
8
use SetBased\Stratum\MySql\Exception\MySqlQueryErrorException;
9
10
/**
11
 * Class for generating a wrapper method for a stored procedure selecting a large amount of rows.
12
 */
13
class BulkWrapper extends MysqlWrapper
14
{
15
  //--------------------------------------------------------------------------------------------------------------------
16
  /**
17
   * @inheritdoc
18
   */
19
  protected function enhancePhpDocBlockParameters(array &$parameters): void
20
  {
21
    $this->imports[] = BulkHandler::class;
22
23
    $parameter = ['php_name'       => '$bulkHandler',
24
                  'description'    => 'The bulk row handler',
25
                  'php_type'       => 'BulkHandler',
26
                  'dtd_identifier' => null];
27
28
    $parameters = array_merge([$parameter], $parameters);
29
  }
30
31
  //--------------------------------------------------------------------------------------------------------------------
32
  /**
33
   * @inheritdoc
34
   */
35
  protected function generateMethodBodyWithLobFetchData(WrapperContext $context): void
36
  {
37
    // Nothing to do.
38
  }
39
40
  //--------------------------------------------------------------------------------------------------------------------
41
  /**
42
   * @inheritdoc
43
   */
44
  protected function generateMethodBodyWithLobReturnData(WrapperContext $context): void
45
  {
46
    // Nothing to do.
47
  }
48
49
  //--------------------------------------------------------------------------------------------------------------------
50
  /**
51
   * @inheritdoc
52
   */
53
  protected function generateMethodBodyWithoutLob(WrapperContext $context): void
54
  {
55
    $this->throws(MySqlQueryErrorException::class);
56
57
    $context->codeStore->append(sprintf("\$this->executeBulk(\$bulkHandler, 'call %s(%s)');",
58
                                        $context->phpStratumMetadata['routine_name'],
59
                                        $this->getRoutineArgs($context)));
60
  }
61
62
  //--------------------------------------------------------------------------------------------------------------------
63
  /**
64
   * @inheritdoc
65
   */
66
  protected function getDocBlockReturnType(WrapperContext $context): string
67
  {
68
    return 'void';
69
  }
70
71
  //--------------------------------------------------------------------------------------------------------------------
72
  /**
73
   * @inheritdoc
74
   */
75
  protected function getReturnTypeDeclaration(WrapperContext $context): string
76
  {
77
    return ': void';
78
  }
79
80
  //--------------------------------------------------------------------------------------------------------------------
81
}
82
83
//----------------------------------------------------------------------------------------------------------------------
84