-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathLanguage.php
More file actions
49 lines (41 loc) · 1.29 KB
/
Language.php
File metadata and controls
49 lines (41 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// Copyright 2022 DeepL SE (https://www.deepl.com)
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
namespace DeepL;
/**
* Information about a language supported by DeepL translator.
*/
class Language
{
/**
* @var string Name of the language in English.
*/
public $name;
/**
* @var string Language code according to ISO 639-1, for example 'en'. Some target languages also include the
* regional variant according to ISO 3166-1, for example 'en-US'.
* @see LanguageCode
*/
public $code;
/**
* @var boolean|null For target languages only, specifies whether the formality option is available for the target
* language. This parameter is null for source languages.
*/
public $supportsFormality;
public function __construct(string $name, string $code, ?bool $supportsFormality)
{
$this->name = $name;
$this->code = $code;
$this->supportsFormality = $supportsFormality;
}
public static function __set_state(array $array)
{
$object = new Language($array['name'], $array['code'], $array['supportsFormality']);
return $object;
}
public function __toString(): string
{
return "$this->name ($this->code)";
}
}