Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Jul 11, 2024
1 parent 29dec3a commit fe9e3d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions lam/lib/import.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Importer {
const STATUS = 'status';
const PROGRESS = 'progress';
const DATA = 'data';
const TIME_LIMIT = 10;
private const TIME_LIMIT = 10;
const KEY = 0;
const VALUE = 1;
const CHANGETYPE = 'changetype';
Expand Down Expand Up @@ -199,11 +199,11 @@ class Importer {
private function getEndTime() {
$startTime = time();
$maxTime = get_cfg_var('max_execution_time') - 10;
if ($maxTime > Importer::TIME_LIMIT) {
$maxTime = Importer::TIME_LIMIT;
if ($maxTime > self::TIME_LIMIT) {
$maxTime = self::TIME_LIMIT;
}
if ($maxTime <= 0) {
$maxTime = Importer::TIME_LIMIT;
$maxTime = self::TIME_LIMIT;
}
return $startTime + $maxTime;
}
Expand Down
18 changes: 9 additions & 9 deletions lam/lib/upload.inc
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ class Uploader {
private $type;
private $endTime;

const TIME_LIMIT = 10;
private const TIME_LIMIT = 10;

public static function cleanSession() {
foreach ($_SESSION as $key => &$value) {
if (strpos($key, 'mass_') === 0) {
if (str_starts_with($key, 'mass_')) {
unset($_SESSION[$key]);
}
}
Expand All @@ -73,11 +73,11 @@ class Uploader {
$this->type = $type;
$startTime = time();
$maxTime = get_cfg_var('max_execution_time') - 5;
if ($maxTime > Uploader::TIME_LIMIT) {
$maxTime = Uploader::TIME_LIMIT;
if ($maxTime > self::TIME_LIMIT) {
$maxTime = self::TIME_LIMIT;
}
if ($maxTime <= 0) {
$maxTime = Uploader::TIME_LIMIT;
$maxTime = self::TIME_LIMIT;
}
$this->endTime = $startTime + $maxTime;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ class Uploader {
unset($attrs['dn']);
// remove informational attributes
foreach ($attrs as $key => $value) {
if (strpos($key, 'INFO.') === 0) {
if (str_starts_with($key, 'INFO.')) {
unset($attrs[$key]);
}
}
Expand Down Expand Up @@ -215,8 +215,8 @@ class Uploader {
$errorHtml = '';
if ($allDone && !empty($_SESSION['mass_errors'])) {
foreach ($_SESSION['mass_errors'] as $error) {
$text = isset($error[2]) ? $error[2] : '';
$vars = isset($error[3]) ? $error[3] : [];
$text = $error[2] ?? '';
$vars = $error[3] ?? [];
$errorHtml .= StatusMessage($error[0], $error[1], $text, $vars, true);
}
}
Expand Down Expand Up @@ -312,7 +312,7 @@ class Uploader {
// get informational attributes
$infoAttributes = [];
foreach ($attrs as $key => $value) {
if (strpos($key, 'INFO.') === 0) {
if (str_starts_with($key, 'INFO.')) {
$infoAttributes[$key] = $value;
}
}
Expand Down

0 comments on commit fe9e3d2

Please sign in to comment.