66use CidiLabs \PhpAlly \PhpAlly ;
77
88class PhpAllyService {
9-
9+
1010 protected $ phpAlly ;
1111
1212 /** @var App\Service\HtmlService */
1313 protected $ htmlService ;
1414
1515 protected $ util ;
16-
16+
1717 public function __construct (HtmlService $ htmlService , UtilityService $ util )
1818 {
19- $ this ->phpAlly = new PhpAlly ();
19+ $ this ->phpAlly = new PhpAlly ();
2020 $ this ->htmlService = $ htmlService ;
2121 $ this ->util = $ util ;
2222 }
@@ -34,7 +34,7 @@ public function scanContentItem(ContentItem $contentItem)
3434 'vimeoApiKey ' => !empty ($ _ENV ['VIMEO_API_KEY ' ]) ? $ _ENV ['VIMEO_API_KEY ' ] : '' ,
3535 'youtubeApiKey ' => !empty ($ _ENV ['YOUTUBE_API_KEY ' ]) ? $ _ENV ['YOUTUBE_API_KEY ' ] : ''
3636 ];
37-
37+
3838 return $ this ->phpAlly ->checkMany ($ html , $ this ->getRules (), $ options );
3939 }
4040
@@ -52,7 +52,7 @@ public function scanHtml($html, $rules = [])
5252 'vimeoApiKey ' => !empty ($ _ENV ['VIMEO_API_KEY ' ]) ? $ _ENV ['VIMEO_API_KEY ' ] : '' ,
5353 'youtubeApiKey ' => !empty ($ _ENV ['YOUTUBE_API_KEY ' ]) ? $ _ENV ['YOUTUBE_API_KEY ' ] : ''
5454 ];
55-
55+
5656 return $ this ->phpAlly ->checkMany ($ html , $ rules , $ options );
5757 }
5858
@@ -68,12 +68,19 @@ public function getRules()
6868
6969 protected function getEnvExcludedRules ()
7070 {
71- return array_map ('trim ' , explode (', ' , $ _ENV ['PHPALLY_EXCLUDED_RULES ' ]));
71+ $ excluded = array_map ('trim ' , explode (', ' , $ _ENV ['PHPALLY_EXCLUDED_RULES ' ]));
72+
73+ return array_map (array ($ this , 'addRulePath ' ), $ excluded );
7274 }
7375
7476 protected function getDbExcludedRules ()
7577 {
7678 // TODO: To be implemented with the admin section
7779 return [];
7880 }
79- }
81+
82+ private function addRulePath ($ rule )
83+ {
84+ return "CidiLabs \\PhpAlly \\Rule \\" . $ rule ;
85+ }
86+ }
0 commit comments