2121
2222class AuditManager
2323{
24- private LoggerInterface $ logger ;
25- private bool $ lighthouse ;
26- private bool $ pa11y ;
27- private bool $ tika ;
28- private bool $ tikaJar ;
29- private CacheManager $ cacheManager ;
30- private bool $ all ;
3124 private Pa11yWrapper $ pa11yAudit ;
3225 private LighthouseWrapper $ lighthouseAudit ;
3326 private TikaWrapper $ tikaLocaleAudit ;
@@ -36,20 +29,9 @@ class AuditManager
3629 private TikaWrapper $ tikaMetaAudit ;
3730 private TikaMetaResponse $ metaRequest ;
3831 private AsyncResponse $ htmlRequest ;
39- private int $ tikaMaxSize ;
40- private string $ tikaServerUrl ;
4132
42- public function __construct (CacheManager $ cacheManager , LoggerInterface $ logger , bool $ all , bool $ pa11y , bool $ lighthouse , bool $ tika , bool $ tikaJar , string $ tikaServerUrl , int $ tikaMaxSize )
33+ public function __construct (private readonly CacheManager $ cacheManager , private readonly LoggerInterface $ logger , private readonly bool $ all , private readonly bool $ pa11y , private readonly bool $ lighthouse , private readonly bool $ tika , private readonly bool $ tikaJar , private readonly string $ tikaServerUrl , private readonly int $ tikaMaxSize )
4334 {
44- $ this ->cacheManager = $ cacheManager ;
45- $ this ->logger = $ logger ;
46- $ this ->pa11y = $ pa11y ;
47- $ this ->lighthouse = $ lighthouse ;
48- $ this ->tikaJar = $ tikaJar ;
49- $ this ->tika = $ tika ;
50- $ this ->all = $ all ;
51- $ this ->tikaMaxSize = $ tikaMaxSize ;
52- $ this ->tikaServerUrl = $ tikaServerUrl ;
5335 }
5436
5537 public function analyze (Url $ url , HttpResult $ result , Report $ report ): AuditResult
@@ -256,8 +238,8 @@ private function addTikaJarAudits(AuditResult $audit, HttpResult $result): void
256238 $ audit ->addLinks (new Url ($ link , $ audit ->getUrl ()->getUrl ()));
257239 }
258240 $ meta = $ this ->tikaMetaAudit ->getJson ();
259- $ audit ->setTitle (null === ($ meta ['dc:title ' ] ?? null ) ? null : \trim ($ meta ['dc:title ' ]));
260- $ audit ->setAuthor (null === ($ meta ['dc:author ' ] ?? null ) ? null : \trim ($ meta ['dc:author ' ]));
241+ $ audit ->setTitle (null === ($ meta ['dc:title ' ] ?? null ) ? null : \trim (( string ) $ meta ['dc:title ' ]));
242+ $ audit ->setAuthor (null === ($ meta ['dc:author ' ] ?? null ) ? null : \trim (( string ) $ meta ['dc:author ' ]));
261243 } catch (\Throwable $ e ) {
262244 $ this ->logger ->critical (\sprintf ('Tika audit for %s failed: %s ' , $ audit ->getUrl ()->getUrl (), $ e ->getMessage ()));
263245 }
@@ -281,7 +263,7 @@ private function addHtmlAudit(AuditResult $audit, HttpResult $result, Report $re
281263 for ($ i = 0 ; $ i < $ content ->count (); ++$ i ) {
282264 $ item = $ content ->eq ($ i );
283265 $ href = $ item ->attr ('href ' );
284- if (null === $ href || 0 === \strlen ($ href ) || ' # ' === \substr ($ href , 0 , 1 )) {
266+ if (null === $ href || 0 === \strlen ($ href ) || str_starts_with ($ href , ' # ' )) {
285267 continue ;
286268 }
287269 $ audit ->addLinks (new Url ($ href , $ audit ->getUrl ()->getUrl ()));
0 commit comments