You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
455 B
PHTML

2 years ago
<?php
namespace App\Services;
class ParseText {
private $data;
public function __construct($text)
{
$this->data = [];
foreach(explode("\n", $text) as $line) {
$row = explode(':', $line);
if(count($row) > 1 && !empty(trim($row[0]))) $this->data[trim($row[0])] = trim($row[1]);
}
// logger($text);
}
public function value($key) {
return $this->data[$key] ?? null;
}
}