Skip to content

Commit d5e9bd5

Browse files
committed
Revert "fix cs"
This reverts commit 12825e2.
1 parent 12825e2 commit d5e9bd5

File tree

10 files changed

+43
-39
lines changed

10 files changed

+43
-39
lines changed

boot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
include_once __DIR__ . '/vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php';
1010
}
1111

12-
if (rex_be_controller::getCurrentPagePart(1) === 'diff_detect') {
12+
if ('diff_detect' === rex_be_controller::getCurrentPagePart(1)) {
1313
rex_view::addJsFile($this->getAssetsUrl('tagsinput.js'));
1414
rex_view::addCssFile($this->getAssetsUrl('tagsinput.css'));
1515
rex_view::addCssFile($this->getAssetsUrl('diff-table.css'));

lib/Index.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use rex_addon;
99
use rex_exception;
1010
use rex_instance_pool_trait;
11+
use rex_socket_exception;
1112
use rex_sql;
12-
use rex_sql_exception;
1313
use voku\helper\HtmlDomParser;
1414

1515
final 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

lib/RssDiff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function calculate(): string
4848
$diff = HtmlDiffAdvanced::create($this->renderItem($item), $this->renderItem($itemsAfter[$id]));
4949
$diffContent = $diff->build();
5050

51-
if ($diff->getDifference() !== '') {
51+
if ('' !== $diff->getDifference()) {
5252
$class = 'modified';
5353
$label = '<span class="label label-info">' . rex_addon::get('diff_detect')->i18n('modified') . '</span>';
5454
} else {

lib/Url.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function get(int $id): ?self
3939
$sql->setWhere('id = ?', [$id]);
4040
$sql->select();
4141

42-
if ($sql->getRows() === null) {
42+
if (null === $sql->getRows()) {
4343
return null;
4444
}
4545

@@ -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

@@ -107,14 +107,14 @@ public function getContent(): rex_socket_response
107107
$login = $this->getValue('http_auth_login');
108108
$password = $this->getValue('http_auth_password');
109109

110-
if ($login === '' && $password === '') {
110+
if ('' === $login && '' === $password) {
111111
$socket->addBasicAuthorization($login, $password);
112112
}
113113

114114
$response = $socket->doGet();
115115
$cookie = $response->getHeader('Set-Cookie');
116116

117-
if ($cookie !== null) {
117+
if (null !== $cookie) {
118118
$socket->addHeader('Cookie', substr($cookie, 0, strpos($cookie, ';')));
119119
$response = $socket->doGet();
120120
}

lib/cronjob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function execute()
4747
$sql->next();
4848
}
4949

50-
if ($sql->getRows() === 0) {
50+
if (0 === $sql->getRows()) {
5151
$messages[] = 'no snapshots';
5252
}
5353

pages/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
$addon = rex_addon::get('diff_detect');
99

10-
if (rex_request('func', 'string') === 'update') {
10+
if ('update' === rex_request('func', 'string')) {
1111
$this->setConfig('cleanup_interval', rex_request('diff_detect_cleanup_interval', 'int', null));
1212
echo rex_view::success($this->i18n('settings_updated'));
1313
}

pages/url.diff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$idBefore = rex_request('before', 'int', null);
77
$idAfter = rex_request('after', 'int', null);
88

9-
if ($urlId === null || $idBefore === null || $idAfter === null) {
9+
if (null === $urlId || null === $idBefore || null === $idAfter) {
1010
echo rex_view::error($this->i18n('diff_error'));
1111
$title = '';
1212
$content = '';
@@ -23,7 +23,7 @@
2323
);
2424

2525
$first_detect = '';
26-
if ($url->getType() === 'RSS') {
26+
if ('RSS' === $url->getType()) {
2727
$content = (new \FriendsOfRedaxo\DiffDetect\RssDiff($indexBefore->getContent(), $indexAfter->getContent()))->calculate();
2828
} else {
2929
$content = \Jfcherng\Diff\DiffHelper::calculate(
@@ -41,7 +41,7 @@
4141
],
4242
);
4343

44-
if ($content === '') {
44+
if ('' === $content) {
4545
$content = '<table class="diff-wrapper diff diff-html diff-combined">
4646
<thead><tr><th>Keine Unterschiede</th></tr></thead>
4747
<tbody class="change change-eq"><tr data-type=" "><td class="new">' . $indexAfter->getContent() . '</td></tr></tbody>

pages/url.form.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$form = rex_diff_detect_form::factory(rex::getTable('diff_detect_url'), '', 'id = ' . $id);
1212
$form->setFormAttribute('autocomplete', 'off');
1313

14-
if ($func === 'edit' && $id > 0) {
14+
if ('edit' === $func && 0 < $id) {
1515
$form->setEditMode(true);
1616
$form->addParam('id', $id);
1717
}
@@ -105,18 +105,20 @@
105105
});
106106

107107
rex_extension::register('REX_FORM_DELETED', static function ($ep) {
108+
108109
/** @var rex_extension_point $ep */
109110
/** @var array<string, mixed> $params */
110111
$params = $ep->getParams();
111112

112-
if (get_class($params['form']) === 'rex_diff_detect_form') {
113+
if ('rex_diff_detect_form' === get_class($params['form'])) {
113114
/** @var rex_diff_detect_form $form */
114115
$form = $params['form'];
115116
$form_params = $form->getParams();
116117

117118
rex_sql::factory()->setQuery('delete from `' . rex::getTable('diff_detect_index') . '` where url_id=:url_id', [
118119
'url_id' => $form_params['id'],
119120
]);
121+
120122
}
121123
});
122124

pages/url.list.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
switch (rex_get('func')) {
1111
case 'status':
12-
if ($id > 0) {
12+
if (0 < $id) {
1313
$status = (bool) rex_get('status', 'bool');
1414

1515
$sql = rex_sql::factory();
@@ -22,7 +22,7 @@
2222
break;
2323

2424
case 'snapshot':
25-
if ($id > 0) {
25+
if (0 < $id) {
2626
$Url = Url::get($id);
2727
try {
2828
if (Index::createSnapshot($Url)) {
@@ -82,17 +82,18 @@
8282
$list->removeColumn('name');
8383

8484
$list->setColumnFormat('url', 'custom', static function ($params) {
85+
8586
/** @var rex_list $list */
8687
$list = $params['list'];
8788

8889
$title = (string) $list->getValue('name');
89-
if (mb_strlen($title) > 60) {
90+
if (60 < mb_strlen($title)) {
9091
$title = mb_substr($title, 0, 25) . ' ... ' . mb_substr($title, -25);
9192
}
9293
$title = '<span class="nowrap" title="' . rex_escape($list->getValue('name')) . '">' . rex_escape($title) . '</span>';
9394

9495
$value = $params['value'];
95-
if (mb_strlen($value) > 60) {
96+
if (60 < mb_strlen($value)) {
9697
$value = mb_substr($value, 0, 25) . ' ... ' . mb_substr($value, -25);
9798
}
9899
$value = '<span class="nowrap"><a href="' . rex_escape($params['value']) . '" title="' . rex_escape($params['value']) . '" target="_blank">' . $value . '</a></span>';
@@ -123,19 +124,19 @@
123124
$urlParams = [
124125
'func' => 'status',
125126
'id' => $list->getValue('id'),
126-
'status' => ($list->getValue('status') === '0') ? '0' : '1',
127+
'status' => ('0' === $list->getValue('status')) ? '0' : '1',
127128
];
128129

129130
$start = rex_request($startKey = $list->getName() . '_start', 'string', '');
130-
if ($start !== '') {
131+
if ('' !== $start) {
131132
$urlParams[$startKey] = $start;
132133
}
133134

134135
$addon = rex_addon::get('diff_detect');
135136
return '<div><a href="' . $list->getUrl(
136137
$urlParams,
137138
) . '" title="' . $addon->i18n(
138-
($list->getValue('status') === '1')
139+
('1' === $list->getValue('status'))
139140
? 'active_title'
140141
: 'inactive_title',
141142
) . '" class="diff-status-' . ($list->getValue(
@@ -174,7 +175,7 @@
174175
$list = $params['list'];
175176
$addon = rex_addon::get('diff_detect');
176177
$checked = $list->getValue('checked');
177-
if ($checked === 1) {
178+
if (1 === $checked) {
178179
$checked = '<span class="label label-success">' . $addon->i18n('checked') . '</span>';
179180
} else {
180181
$checked = '<span class="label label-warning">' . $addon->i18n('not_checked') . '</span>';
@@ -193,7 +194,7 @@
193194
];
194195

195196
$start = rex_request($startKey = $list->getName() . '_start', 'string', '');
196-
if ($start !== '') {
197+
if ('' !== $start) {
197198
$urlParams[$startKey] = $start;
198199
}
199200

pages/url.snapshots.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
$checked = rex_get('checked', 'int', null);
1010
$indexId = rex_request('index_id', 'int', null);
1111

12-
if ($checked !== null && $indexId !== null) {
12+
if (null !== $checked && null !== $indexId) {
1313
$sql = rex_sql::factory();
1414
$sql->setTable(rex::getTable('diff_detect_index'));
1515
$sql->setWhere('id = :id', ['id' => $indexId]);
16-
$sql->setValue('checked', $checked === 1 ? 1 : 0);
16+
$sql->setValue('checked', 1 === $checked ? 1 : 0);
1717
$sql->addGlobalUpdateFields();
1818
$sql->update();
19-
echo rex_view::success(($checked === 1) ? rex_i18n::msg('index_checked') : rex_i18n::msg('index_not_checked'));
19+
echo rex_view::success((1 === $checked) ? rex_i18n::msg('index_checked') : rex_i18n::msg('index_not_checked'));
2020
}
2121

2222
$Url = \FriendsOfRedaxo\DiffDetect\Url::get((int) $urlId);
23-
if ($Url === null) {
23+
if (null === $Url) {
2424
echo rex_view::error(rex_i18n::msg('diff_detect_url_not_found'));
2525
return;
2626
}
@@ -33,15 +33,15 @@
3333
$checkedBefore = '';
3434
$checkedAfter = '';
3535

36-
if ($idBefore === null && $counter === 1) {
36+
if (null === $idBefore && 1 === $counter) {
3737
$checkedBefore = ' checked';
3838
}
3939
if ($idBefore === $snapshot['id']) {
4040
$checkedBefore = ' checked';
4141
}
42-
if ($idAfter === $snapshot['id']
43-
|| count($Snapshots) === 1
44-
|| ($idAfter === null && $counter === 2)) {
42+
if ($idAfter === $snapshot['id'] ||
43+
1 === count($Snapshots) ||
44+
(null === $idAfter && 2 === $counter)) {
4545
$checkedAfter = ' checked';
4646
}
4747

@@ -56,7 +56,7 @@
5656
<td>' . rex_escape(rex_formatter::intlDateTime((string) $snapshot['createdate'], IntlDateFormatter::MEDIUM)) . '</td>
5757
<td>' . rex_escape($snapshot['createuser']) . '</td>
5858
<td>' . rex_escape(rex_formatter::bytes($snapshot['size'], [2])) . '</td>
59-
<td><a href="index.php?page=diff_detect/dashboard&func=snapshots&id=' . $urlId . '&index_id=' . $snapshot['id'] . '&checked=' . ($snapshot['checked'] === 1 ? 0 : 1) . '">' . ($snapshot['checked'] === 1 ? $this->i18n('checked') : $this->i18n('not_checked')) . '</a></td>
59+
<td><a href="index.php?page=diff_detect/dashboard&func=snapshots&id=' . $urlId . '&index_id=' . $snapshot['id'] . '&checked=' . (1 === $snapshot['checked'] ? 0 : 1) . '">' . (1 === $snapshot['checked'] ? $this->i18n('checked') : $this->i18n('not_checked')) . '</a></td>
6060
</tr>';
6161
}
6262

0 commit comments

Comments
 (0)