AbstractRoutine   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
showCreate() 0 1 ?
createQuery() 0 1 ?
A write() 0 15 2
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDbDump/ for the canonical source repository
6
 * @copyright   Copyright (c) 2014-2017 Webino, s. r. o. (http://webino.sk)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDbDump\Db\Dump\Platform\Mysql\Routine;
11
12
use ArrayObject;
13
use SplFileObject as File;
14
use WebinoDbDump\Db\Dump\Table\AbstractExtra;
15
use Zend\Db\ResultSet\ResultSet;
16
17
/**
18
 * Mysql database dump utility platform routine
19
 *
20
 * @author Peter Bačinský <[email protected]>
21
 */
22
abstract class AbstractRoutine extends AbstractExtra
23
{
24
    /**
25
     * @param string $identifier
26
     * @return string
27
     */
28
    abstract protected function showCreate($identifier);
29
30
    /**
31
     * @param string $identifier
32
     * @param ArrayObject $create
33
     * @return string
34
     */
35
    abstract protected function createQuery($identifier, ArrayObject $create);
36
37
    /**
38
     * @param File $file
39
     * @param ResultSet $procedures
40
     * @return $this
41
     */
42
    protected function write(File $file, ResultSet $procedures)
43
    {
44
        $file->fwrite('DELIMITER ;;' . PHP_EOL . PHP_EOL);
45
46
        $platform = $this->getPlatform();
47
        foreach ($procedures as $procedure) {
48
            $identifier = $platform->quoteIdentifier($procedure['Name']);
49
            $create     = $this->showCreate($identifier)->current();
0 ignored issues
show
Bug introduced by
The method current cannot be called on $this->showCreate($identifier) (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
50
51
            $file->fwrite($this->createQuery($identifier, $create) . PHP_EOL . PHP_EOL);
52
        }
53
54
        $file->fwrite('DELIMITER ;' . PHP_EOL . PHP_EOL);
55
        return $this;
56
    }
57
}
58