23 $definitionStartNewline = $this->getStartingNewLinesCount( $definition );
24 $translationStartNewline = $this->getStartingNewLinesCount( $translation );
26 $failingChecks = $this->validateStartingNewline(
27 $definitionStartNewline, $translationStartNewline
30 return $this->createIssues( $failingChecks );
33 protected function getStartingNewLinesCount(
string $str ):
int {
34 return strspn( $str,
"\n" );
37 protected function getEndingNewLineCount(
string $str ):
int {
38 return strspn( strrev( $str ),
"\n" );
41 protected function validateStartingNewline(
42 int $definitionStartNewline,
43 int $translationStartNewline
46 if ( $definitionStartNewline < $translationStartNewline ) {
50 $translationStartNewline - $definitionStartNewline
52 } elseif ( $definitionStartNewline > $translationStartNewline ) {
56 $definitionStartNewline - $translationStartNewline
60 return $failingChecks;
63 protected function validateEndingNewline(
64 int $definitionEndNewline,
65 int $translationEndNewline
68 if ( $definitionEndNewline < $translationEndNewline ) {
72 $translationEndNewline - $definitionEndNewline
74 } elseif ( $definitionEndNewline > $translationEndNewline ) {
78 $definitionEndNewline - $translationEndNewline
82 return $failingChecks;
87 foreach ( $failingChecks as [ $subType, $count ] ) {
91 "translate-checks-newline-$subType",
95 $issues->add( $issue );