summaryrefslogtreecommitdiff
path: root/src/Etym.php
diff options
context:
space:
mode:
authorPhil Burton <phil@d3r.com>2019-06-11 15:20:45 +0100
committerPhil Burton <phil@d3r.com>2019-06-11 15:20:45 +0100
commita388c59e487607b6e86c5b82a99605275e5f13d4 (patch)
tree836057cf20f2b07bbc54ff7c11378f59a6e06de3 /src/Etym.php
parentd8ffff6171b433b4e0a1b0849c060c9e1051734f (diff)
Remove bad handling of truncation
Diffstat (limited to 'src/Etym.php')
-rw-r--r--src/Etym.php33
1 files changed, 1 insertions, 32 deletions
diff --git a/src/Etym.php b/src/Etym.php
index 8be0a99..39514f8 100644
--- a/src/Etym.php
+++ b/src/Etym.php
@@ -24,7 +24,7 @@ class Etym
* @param string $pasteCmd
* @author Phil Burton <phil@pgburton.com>
*/
- public function __construct(string $baseURL, string $domSearch, string $pasteCmd)
+ public function __construct(string $baseURL, string $domSearch)
{
$this->baseURL = $baseURL;
$this->domSearch = $domSearch;
@@ -53,7 +53,6 @@ class Etym
}
$definition = $this->cleanUpHtml($html[0]->innerHtml());
- $definition = $this->handleTruncation($input, $definition, $targetURL);
// echo $definition . "\n";
return $definition;
@@ -103,34 +102,4 @@ class Etym
return $clear;
}
-
- /**
- * Handle when string is too long
- *
- * @param string $input
- * @param string $definition
- * @param string $url
- * @return string
- * @author Phil Burton <phil@pgburton.com>
- */
- protected function handleTruncation(string $input, string $definition, string $url): string
- {
- $truncated = $definition;
-
- $MAX_CHARACTERS = 350;
- if (strlen($truncated) >= $MAX_CHARACTERS) {
- // Create that povjee link.
- // Capitalise the first char of the input.
- $input = ucfirst($input);
- $defAndUrl = "\"$input\"" . "\n\n" . $definition . "\n\n" . "[Original at: $url]";
-
- $safeDef = escapeshellarg($defAndUrl);
-
- $pasteBinCmd = "echo $safeDef | " . $this->pasteCmd;
- $pasteBinLink = exec($pasteBinCmd);
- $truncated = substr($truncated, 0, $MAX_CHARACTERS) . "... [More info at $pasteBinLink]";
- }
-
- return $truncated;
- }
}