Passed
Push — feature/collation ( 3b40b8...35613b )
by Kit Loong
64:11
created

Repository::getStringLiteralQuoteCharacter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace KitLoong\MigrationsGenerator\Repositories;
4
5
abstract class Repository
6
{
7
    /**
8
     * Quotes a literal string.
9
     * This method is NOT meant to fix SQL injections!
10
     * It is only meant to escape this platform's string literal
11
     * quote character inside the given literal string.
12
     *
13
     * @param  string  $str  The literal string to be quoted.
14
     *
15
     * @return string The quoted literal string.
16
     */
17
    protected function quoteStringLiteral(string $str): string
18
    {
19
        $c = $this->getStringLiteralQuoteCharacter();
20
21
        return $c.str_replace($c, $c.$c, $str).$c;
22
    }
23
24
    /**
25
     * Gets the character used for string literal quoting.
26
     *
27
     * @return string
28
     */
29
    protected function getStringLiteralQuoteCharacter(): string
30
    {
31
        return "'";
32
    }
33
}
34