ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
Utilities.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
25 class Utilities implements UtilitiesInterface
26 {
27  protected \ilLanguage $lng;
28  protected \ilObjUser $user;
29 
30  public function __construct(
31  \ilLanguage $lng,
32  \ilObjUser $user,
33  ) {
34  $this->lng = $lng;
35  $this->lng->loadLanguageModule('meta');
36  $this->user = $user;
37  }
38 
39  public function getUserDateFormat(): DateFormat
40  {
41  return $this->user->getDateFormat();
42  }
43 
44  public function txt(string $key): string
45  {
46  return $this->lng->txt($key);
47  }
48 
49  public function txtFill(string $key, string ...$values): string
50  {
51  if ($this->lng->exists($key)) {
52  return sprintf($this->lng->txt($key), ...$values);
53  }
54  return $key . ' ' . implode(', ', $values);
55  }
56 
57  public function sanitizeForHTML(string $string): string
58  {
59  return htmlspecialchars(
60  $string,
61  ENT_QUOTES | ENT_SUBSTITUTE,
62  'utf-8'
63  );
64  }
65 }
txtFill(string $key, string ... $values)
Definition: Utilities.php:49
A Date Format provides a format definition akin to PHP&#39;s date formatting options, but stores the sing...
Definition: DateFormat.php:26
__construct(\ilLanguage $lng, \ilObjUser $user,)
Definition: Utilities.php:30
string $key
Consumer key/client ID value.
Definition: System.php:193