-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStandardRuleSets.php
More file actions
129 lines (120 loc) · 3.57 KB
/
StandardRuleSets.php
File metadata and controls
129 lines (120 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
declare(strict_types=1);
namespace TwigA11y\Standard;
use TwigA11y\Rules\Aria\AriaHiddenFocusRule;
use TwigA11y\Rules\Aria\AriaLabelRule;
use TwigA11y\Rules\Aria\AriaRequiredAttrRule;
use TwigA11y\Rules\Aria\AriaRoleRule;
use TwigA11y\Rules\Aria\TabIndexRule;
use TwigA11y\Rules\Forms\FormLabelRule;
use TwigA11y\Rules\Forms\InputLabelRule;
use TwigA11y\Rules\Forms\InputTypeRule;
use TwigA11y\Rules\Forms\SelectLabelRule;
use TwigA11y\Rules\Forms\TextareaLabelRule;
use TwigA11y\Rules\Media\AutoplayRule;
use TwigA11y\Rules\Media\ImgAltRule;
use TwigA11y\Rules\Media\ObjectAltRule;
use TwigA11y\Rules\Media\VideoTrackRule;
use TwigA11y\Rules\Structure\AnchorContentRule;
use TwigA11y\Rules\Structure\BannedTagsRule;
use TwigA11y\Rules\Structure\ButtonContentRule;
use TwigA11y\Rules\Structure\DuplicateIdRule;
use TwigA11y\Rules\Structure\HeadingEmptyRule;
use TwigA11y\Rules\Structure\HeadingOrderRule;
use TwigA11y\Rules\Structure\IframeTitleRule;
use TwigA11y\Rules\Structure\LandmarkRule;
use TwigA11y\Rules\Structure\LangAttributeRule;
use TwigA11y\Rules\Structure\MetaViewportRule;
use TwigA11y\Rules\Structure\SkipLinkRule;
use TwigA11y\Rules\Structure\TableHeaderRule;
use TwigA11y\Rules\Ui\ColorContrastRule;
use TwigCsFixer\Rules\RuleInterface;
final class StandardRuleSets
{
/**
* @return list<RuleInterface>
*/
public static function basic(): array
{
return self::instantiate([
ImgAltRule::class,
BannedTagsRule::class,
ButtonContentRule::class,
InputLabelRule::class,
LangAttributeRule::class,
]);
}
/**
* @return list<RuleInterface>
*/
public static function recommended(): array
{
return self::instantiate([
...self::classes(self::basic()),
ObjectAltRule::class,
VideoTrackRule::class,
HeadingOrderRule::class,
IframeTitleRule::class,
DuplicateIdRule::class,
LandmarkRule::class,
FormLabelRule::class,
SelectLabelRule::class,
TextareaLabelRule::class,
]);
}
/**
* @return list<RuleInterface>
*/
public static function standard(): array
{
return self::instantiate([
...self::classes(self::recommended()),
AutoplayRule::class,
AnchorContentRule::class,
HeadingEmptyRule::class,
MetaViewportRule::class,
SkipLinkRule::class,
TableHeaderRule::class,
TabIndexRule::class,
InputTypeRule::class,
]);
}
/**
* @return list<RuleInterface>
*/
public static function strict(): array
{
return self::instantiate([
...self::classes(self::standard()),
AriaRoleRule::class,
AriaLabelRule::class,
AriaHiddenFocusRule::class,
AriaRequiredAttrRule::class,
ColorContrastRule::class,
]);
}
/**
* @param list<class-string<RuleInterface>> $classes
*
* @return list<RuleInterface>
*/
private static function instantiate(array $classes): array
{
return array_map(
static fn (string $class): RuleInterface => new $class(),
$classes
);
}
/**
* @param list<RuleInterface> $rules
*
* @return list<class-string<RuleInterface>>
*/
private static function classes(array $rules): array
{
return array_map(
static fn (RuleInterface $rule): string => $rule::class,
$rules
);
}
}