[icinga-checkins] icinga.org: icingaweb2/feature/translation-catalog-object-13012: CatalogEntry: Restructure method splitStringAtCharLimit
git at icinga.org
git at icinga.org
Tue Nov 22 09:23:08 CET 2016
Module: icingaweb2
Branch: feature/translation-catalog-object-13012
Commit: 604c7a68a24e20ea13e02b30e640bd2b641c8593
URL: https://git.icinga.org/?p=icingaweb2.git;a=commit;h=604c7a68a24e20ea13e02b30e640bd2b641c8593
Author: Noah Hilverling <noah.hilverling at netways.de>
Date: Tue Nov 22 09:22:06 2016 +0100
CatalogEntry: Restructure method splitStringAtCharLimit
---
.../library/Translation/Catalog/CatalogEntry.php | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/modules/translation/library/Translation/Catalog/CatalogEntry.php b/modules/translation/library/Translation/Catalog/CatalogEntry.php
index b0ec637..63a17b5 100644
--- a/modules/translation/library/Translation/Catalog/CatalogEntry.php
+++ b/modules/translation/library/Translation/Catalog/CatalogEntry.php
@@ -649,7 +649,7 @@ class CatalogEntry
}
/**
- * Split a string at char limit
+ * Split a string into lines at char limit
*
* @param string $string The string to split
* @param bool $isPrevious Whether given string is marked previous
@@ -665,29 +665,25 @@ class CatalogEntry
$splitLines = array();
$lastSpace = 0;
$lastCut = 0;
- $isAtEnd = false;
for ($i = 0; $i < strlen($string); $i++)
{
- if ($i == strlen($string) - 1) {
- $isAtEnd = true;
- }
-
if ($string[$i] === ' ') {
$lastSpace = $i;
}
- if ($i >= ($lastCut + self::MAX_LINE_LENGTH) || $isAtEnd) {
+ if ($i >= ($lastCut + self::MAX_LINE_LENGTH)) {
$splitPart = substr($string, $lastCut, $lastSpace - $lastCut + 1);
if ($lastCut == 0) {
$splitLines[] = $splitPart . '"';
} else {
- $splitLines[] = ($isPrevious ? '#| "' : '"') . $splitPart . ($isAtEnd ? '' : '"');
+ $splitLines[] = ($isPrevious ? '#| "' : '"') . $splitPart . '"';
}
$lastCut = $lastSpace + 1;
}
}
+ $splitLines[] = ($isPrevious ? '#| "' : '"') . substr($string, $lastCut, $lastSpace - $lastCut + 1);
return $splitLines;
}
More information about the icinga-checkins
mailing list