1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace gossi\codegen\generator; |
5
|
|
|
|
6
|
|
|
use gossi\codegen\generator\comparator\DefaultConstantComparator; |
7
|
|
|
use gossi\codegen\generator\comparator\DefaultMethodComparator; |
8
|
|
|
use gossi\codegen\generator\comparator\DefaultPropertyComparator; |
9
|
|
|
use gossi\codegen\generator\comparator\DefaultUseStatementComparator; |
10
|
|
|
use phootwork\lang\Comparator; |
11
|
|
|
|
12
|
|
|
class ComparatorFactory { |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Creates a comparator for use statements |
16
|
|
|
* |
17
|
|
|
* @param string $type |
18
|
|
|
* @return Comparator |
19
|
|
|
*/ |
20
|
16 |
|
public static function createUseStatementComparator(string $type): Comparator { |
|
|
|
|
21
|
|
|
// switch ($type) { |
22
|
|
|
// case CodeGenerator::SORT_USESTATEMENTS_DEFAULT: |
23
|
|
|
// default: |
24
|
|
|
// return new DefaultUseStatementComparator(); |
25
|
|
|
// } |
26
|
16 |
|
return new DefaultUseStatementComparator(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Creates a comparator for constants |
31
|
|
|
* |
32
|
|
|
* @param string $type |
33
|
|
|
* @return Comparator |
34
|
|
|
*/ |
35
|
15 |
|
public static function createConstantComparator(string $type): Comparator { |
|
|
|
|
36
|
|
|
// switch ($type) { |
37
|
|
|
// case CodeGenerator::SORT_CONSTANTS_DEFAULT: |
38
|
|
|
// default: |
39
|
|
|
// return new DefaultConstantComparator(); |
40
|
|
|
// } |
41
|
15 |
|
return new DefaultConstantComparator(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Creates a comparator for properties |
46
|
|
|
* |
47
|
|
|
* @param string $type |
48
|
|
|
* @return Comparator |
49
|
|
|
*/ |
50
|
14 |
|
public static function createPropertyComparator(string $type): Comparator { |
|
|
|
|
51
|
|
|
// switch ($type) { |
52
|
|
|
// case CodeGenerator::SORT_PROPERTIES_DEFAULT: |
53
|
|
|
// default: |
54
|
|
|
// return new DefaultPropertyComparator(); |
55
|
|
|
// } |
56
|
14 |
|
return new DefaultPropertyComparator(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Creates a comparator for methods |
61
|
|
|
* |
62
|
|
|
* @param string $type |
63
|
|
|
* @return Comparator |
64
|
|
|
*/ |
65
|
16 |
|
public static function createMethodComparator(string $type): Comparator { |
|
|
|
|
66
|
|
|
// switch ($type) { |
67
|
|
|
// case CodeGenerator::SORT_METHODS_DEFAULT: |
68
|
|
|
// default: |
69
|
|
|
// return new DefaultMethodComparator(); |
70
|
|
|
// } |
71
|
16 |
|
return new DefaultMethodComparator(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.