Skip to content

Commit 12825e2

Browse files
committed
fix cs
1 parent e23c509 commit 12825e2

File tree

10 files changed

+39
-43
lines changed

10 files changed

+39
-43
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 ('diff_detect' === rex_be_controller::getCurrentPagePart(1)) {
12+
if (rex_be_controller::getCurrentPagePart(1) === 'diff_detect') {
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: 8 additions & 9 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;
1211
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 (null === $sql->getRows()) {
43+
if ($sql->getRows() === null) {
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 ('id' === $key) {
77+
if ($key === 'id') {
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 ('HTML' === $url->getType()) {
109+
if ($url->getType() === 'HTML') {
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 (null === $cleanup_interval || 0 === $cleanup_interval) {
150+
if ($cleanup_interval === null || $cleanup_interval === 0) {
151151
return;
152152
}
153153

@@ -160,10 +160,9 @@ public static function cleanUpSnapshots(): void
160160
'interval' => $cleanup_interval,
161161
]);
162162
$sql->delete();
163-
if (null !== $sql->getError()) {
163+
if ($sql->getError() !== null) {
164164
throw new rex_exception($sql->getError());
165165
}
166-
167166
}
168167

169168
public function setUrl(Url $url): self
@@ -180,7 +179,7 @@ public function getUrl(): ?Url
180179

181180
public function getContent(): string
182181
{
183-
if ('RSS' === $this->url?->getType()) {
182+
if ($this->url?->getType() === 'RSS') {
184183
return $this->getValue('content');
185184
}
186185

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 (null === $sql->getRows()) {
42+
if ($sql->getRows() === null) {
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 ('id' === $key) {
77+
if ($key === 'id') {
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 (null !== $cookie) {
117+
if ($cookie !== null) {
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 (0 === $sql->getRows()) {
50+
if ($sql->getRows() === 0) {
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 ('update' === rex_request('func', 'string')) {
10+
if (rex_request('func', 'string') === 'update') {
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 (null === $urlId || null === $idBefore || null === $idAfter) {
9+
if ($urlId === null || $idBefore === null || $idAfter === null) {
1010
echo rex_view::error($this->i18n('diff_error'));
1111
$title = '';
1212
$content = '';
@@ -23,7 +23,7 @@
2323
);
2424

2525
$first_detect = '';
26-
if ('RSS' === $url->getType()) {
26+
if ($url->getType() === 'RSS') {
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: 2 additions & 4 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 ('edit' === $func && 0 < $id) {
14+
if ($func === 'edit' && $id > 0) {
1515
$form->setEditMode(true);
1616
$form->addParam('id', $id);
1717
}
@@ -105,20 +105,18 @@
105105
});
106106

107107
rex_extension::register('REX_FORM_DELETED', static function ($ep) {
108-
109108
/** @var rex_extension_point $ep */
110109
/** @var array<string, mixed> $params */
111110
$params = $ep->getParams();
112111

113-
if ('rex_diff_detect_form' === get_class($params['form'])) {
112+
if (get_class($params['form']) === 'rex_diff_detect_form') {
114113
/** @var rex_diff_detect_form $form */
115114
$form = $params['form'];
116115
$form_params = $form->getParams();
117116

118117
rex_sql::factory()->setQuery('delete from `' . rex::getTable('diff_detect_index') . '` where url_id=:url_id', [
119118
'url_id' => $form_params['id'],
120119
]);
121-
122120
}
123121
});
124122

pages/url.list.php

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

1010
switch (rex_get('func')) {
1111
case 'status':
12-
if (0 < $id) {
12+
if ($id > 0) {
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 (0 < $id) {
25+
if ($id > 0) {
2626
$Url = Url::get($id);
2727
try {
2828
if (Index::createSnapshot($Url)) {
@@ -82,18 +82,17 @@
8282
$list->removeColumn('name');
8383

8484
$list->setColumnFormat('url', 'custom', static function ($params) {
85-
8685
/** @var rex_list $list */
8786
$list = $params['list'];
8887

8988
$title = (string) $list->getValue('name');
90-
if (60 < mb_strlen($title)) {
89+
if (mb_strlen($title) > 60) {
9190
$title = mb_substr($title, 0, 25) . ' ... ' . mb_substr($title, -25);
9291
}
9392
$title = '<span class="nowrap" title="' . rex_escape($list->getValue('name')) . '">' . rex_escape($title) . '</span>';
9493

9594
$value = $params['value'];
96-
if (60 < mb_strlen($value)) {
95+
if (mb_strlen($value) > 60) {
9796
$value = mb_substr($value, 0, 25) . ' ... ' . mb_substr($value, -25);
9897
}
9998
$value = '<span class="nowrap"><a href="' . rex_escape($params['value']) . '" title="' . rex_escape($params['value']) . '" target="_blank">' . $value . '</a></span>';
@@ -124,19 +123,19 @@
124123
$urlParams = [
125124
'func' => 'status',
126125
'id' => $list->getValue('id'),
127-
'status' => ('0' === $list->getValue('status')) ? '0' : '1',
126+
'status' => ($list->getValue('status') === '0') ? '0' : '1',
128127
];
129128

130129
$start = rex_request($startKey = $list->getName() . '_start', 'string', '');
131-
if ('' !== $start) {
130+
if ($start !== '') {
132131
$urlParams[$startKey] = $start;
133132
}
134133

135134
$addon = rex_addon::get('diff_detect');
136135
return '<div><a href="' . $list->getUrl(
137136
$urlParams,
138137
) . '" title="' . $addon->i18n(
139-
('1' === $list->getValue('status'))
138+
($list->getValue('status') === '1')
140139
? 'active_title'
141140
: 'inactive_title',
142141
) . '" class="diff-status-' . ($list->getValue(
@@ -175,7 +174,7 @@
175174
$list = $params['list'];
176175
$addon = rex_addon::get('diff_detect');
177176
$checked = $list->getValue('checked');
178-
if (1 === $checked) {
177+
if ($checked === 1) {
179178
$checked = '<span class="label label-success">' . $addon->i18n('checked') . '</span>';
180179
} else {
181180
$checked = '<span class="label label-warning">' . $addon->i18n('not_checked') . '</span>';
@@ -194,7 +193,7 @@
194193
];
195194

196195
$start = rex_request($startKey = $list->getName() . '_start', 'string', '');
197-
if ('' !== $start) {
196+
if ($start !== '') {
198197
$urlParams[$startKey] = $start;
199198
}
200199

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

2222
$Url = \FriendsOfRedaxo\DiffDetect\Url::get((int) $urlId);
23-
if (null === $Url) {
23+
if ($Url === null) {
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 (null === $idBefore && 1 === $counter) {
36+
if ($idBefore === null && $counter === 1) {
3737
$checkedBefore = ' checked';
3838
}
3939
if ($idBefore === $snapshot['id']) {
4040
$checkedBefore = ' checked';
4141
}
42-
if ($idAfter === $snapshot['id'] ||
43-
1 === count($Snapshots) ||
44-
(null === $idAfter && 2 === $counter)) {
42+
if ($idAfter === $snapshot['id']
43+
|| count($Snapshots) === 1
44+
|| ($idAfter === null && $counter === 2)) {
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=' . (1 === $snapshot['checked'] ? 0 : 1) . '">' . (1 === $snapshot['checked'] ? $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=' . ($snapshot['checked'] === 1 ? 0 : 1) . '">' . ($snapshot['checked'] === 1 ? $this->i18n('checked') : $this->i18n('not_checked')) . '</a></td>
6060
</tr>';
6161
}
6262

0 commit comments

Comments
 (0)