88use rex_addon ;
99use rex_exception ;
1010use rex_instance_pool_trait ;
11+ use rex_socket_exception ;
1112use rex_sql ;
12- use rex_sql_exception ;
1313use voku \helper \HtmlDomParser ;
1414
1515final class Index
@@ -40,7 +40,7 @@ public static function get(int $id): ?self
4040 $ sql ->setWhere ('id = ? ' , [$ id ]);
4141 $ sql ->select ();
4242
43- if ($ sql ->getRows () === null ) {
43+ if (null === $ sql ->getRows ()) {
4444 return null ;
4545 }
4646
@@ -74,7 +74,7 @@ public function setValue(string $key, mixed $value): self
7474
7575 public function getValue (string $ key ): mixed
7676 {
77- if ($ key === ' id ' ) {
77+ if (' id ' === $ key ) {
7878 return $ this ->id ;
7979 }
8080
@@ -98,15 +98,15 @@ private static function fromSqlData(array $data): self
9898 }
9999
100100 /**
101- * @throws rex_sql_exception
101+ * @throws \ rex_sql_exception
102102 */
103103 public static function createSnapshot (Url $ url ): bool
104104 {
105105 $ url ->setLastScan ();
106106 $ response = $ url ->getContent ();
107107 $ content = $ response ->getBody ();
108108
109- if ($ url ->getType () === ' HTML ' ) {
109+ if (' HTML ' === $ url ->getType ()) {
110110 $ content = preg_replace ('/<script\b[^>]*>(.*?)<\/script>/is ' , '' , $ content );
111111 $ content = preg_replace ('/<style\b[^>]*>(.*?)<\/style>/is ' , '' , $ content );
112112 $ content = preg_replace ('/<noscript\b[^>]*>(.*?)<\/noscript>/is ' , '' , $ content );
@@ -147,7 +147,7 @@ public static function cleanUpSnapshots(): void
147147 $ addon = rex_addon::get ('diff_detect ' );
148148 $ cleanup_interval = $ addon ->getConfig ('cleanup_interval ' );
149149
150- if ($ cleanup_interval === null || $ cleanup_interval === 0 ) {
150+ if (null === $ cleanup_interval || 0 === $ cleanup_interval ) {
151151 return ;
152152 }
153153
@@ -160,9 +160,10 @@ public static function cleanUpSnapshots(): void
160160 'interval ' => $ cleanup_interval ,
161161 ]);
162162 $ sql ->delete ();
163- if ($ sql ->getError () !== null ) {
163+ if (null !== $ sql ->getError ()) {
164164 throw new rex_exception ($ sql ->getError ());
165165 }
166+
166167 }
167168
168169 public function setUrl (Url $ url ): self
@@ -179,7 +180,7 @@ public function getUrl(): ?Url
179180
180181 public function getContent (): string
181182 {
182- if ($ this ->url ?->getType() === ' RSS ' ) {
183+ if (' RSS ' === $ this ->url ?->getType()) {
183184 return $ this ->getValue ('content ' );
184185 }
185186
0 commit comments