File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 1515use Worksome \UkTaxCodeValidator \Rules \NoTaxesRule ;
1616use Worksome \UkTaxCodeValidator \Rules \RuleInterface ;
1717use Worksome \UkTaxCodeValidator \Rules \TemporaryTaxCodeRule ;
18+ use Worksome \UkTaxCodeValidator \Rules \AdvancedScottishRateRule ;
1819use Worksome \UkTaxCodeValidator \Rules \TopScottishRateRule ;
1920use Worksome \UkTaxCodeValidator \TaxCode ;
2021
@@ -35,6 +36,7 @@ public function __construct()
3536 new MarriageAllowanceTransferredRule ($ this ),
3637 new HigherRateRule ($ this ),
3738 new AdditionalRateRule ($ this ),
39+ new AdvancedScottishRateRule ($ this ),
3840 new TopScottishRateRule ($ this ),
3941 new NoTaxesRule ($ this ),
4042 ];
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Worksome \UkTaxCodeValidator \Rules ;
4+
5+ use Worksome \UkTaxCodeValidator \TaxCode ;
6+
7+ class AdvancedScottishRateRule extends RegexRule
8+ {
9+ public function validate (TaxCode $ taxCode ): bool
10+ {
11+ // Validate against full tax code, as a D2
12+ // should always have a scottish regime modifier in front.
13+ return parent ::validate (
14+ new TaxCode ($ taxCode ->getOriginalTaxCode ())
15+ );
16+ }
17+
18+ protected function regex (): string
19+ {
20+ return /* @lang RegExp */ '/^SD2/ ' ;
21+ }
22+
23+ protected function regexForConsume (): string
24+ {
25+ return /* @lang RegExp */ '/^D2/ ' ;
26+ }
27+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ class TopScottishRateRule extends RegexRule
88{
99 public function validate (TaxCode $ taxCode ): bool
1010 {
11- // Validate against full tax code, as a D2
11+ // Validate against full tax code, as a D3
1212 // should always have a scottish regime modifier in front.
1313 return parent ::validate (
1414 new TaxCode ($ taxCode ->getOriginalTaxCode ())
@@ -17,11 +17,11 @@ public function validate(TaxCode $taxCode): bool
1717
1818 protected function regex (): string
1919 {
20- return /* @lang RegExp */ '/^SD2 / ' ;
20+ return /* @lang RegExp */ '/^SD3 / ' ;
2121 }
2222
2323 protected function regexForConsume (): string
2424 {
25- return /* @lang RegExp */ '/^D2 / ' ;
25+ return /* @lang RegExp */ '/^D3 / ' ;
2626 }
2727}
Original file line number Diff line number Diff line change 2828 // Not taxed
2929 'NT ' , 'NTX ' , 'NTM1 ' ,
3030 // Top scottish rates
31+ 'SD3 ' , 'SD3X ' ,
32+ // Advanced scottish rates
3133 'SD2 ' , 'SD2X ' ,
3234 // Random tests
3335 'S 123 3 L ' ,
You can’t perform that action at this time.
0 commit comments