Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Util
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
6 / 6
7
100.00% covered (success)
100.00%
1 / 1
 quoteList
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 quote
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 quoteAndJoin
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 splitThenQuoteAndJoin
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 splitAndQuote
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 splitAndQuoteThenJoin
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Projom\Storage\SQL;
6
7use Projom\Storage\Util as StorageUtil;
8
9class Util extends StorageUtil
10{
11    public static function quoteList(array $list): array
12    {
13        return array_map([static::class, 'quote'], $list);
14    }
15
16    public static function quote(string $subject): string
17    {
18        $subject = static::cleanString($subject);
19
20        if ($subject === '*')
21            return $subject;
22
23        return "`$subject`";
24    }
25
26    public static function quoteAndJoin(array $list, string $delimeter = ','): string
27    {
28        return static::join(static::quoteList($list), $delimeter);
29    }
30
31    public static function splitThenQuoteAndJoin(string $subject, string $delimeter = ','): string
32    {
33        return static::quoteAndJoin(static::split($subject, $delimeter), $delimeter);
34    }
35
36    public static function splitAndQuote(string $subject, string $delimeter = ','): array
37    {
38        return static::quoteList(static::split($subject, $delimeter));
39    }
40
41    public static function splitAndQuoteThenJoin(string $subject, string $delimeter = ','): string
42    {
43        return static::join(static::splitAndQuote($subject, $delimeter), $delimeter);
44    }
45}