-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathOptions.php
More file actions
37 lines (31 loc) Β· 824 Bytes
/
Options.php
File metadata and controls
37 lines (31 loc) Β· 824 Bytes
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
<?php
namespace LanguageServer;
class Options
{
/**
* Filetypes the indexer should process
*
* @var array
*/
public $fileTypes = [".php"];
/**
* @param \stdClass|null $options
*/
public function __construct(\stdClass $options = null)
{
// Do nothing when the $options parameter is not an object
if (!is_object($options)) {
return;
}
$this->fileTypes = $options->fileTypes ?? $this->normalizeFileTypes($this->fileTypes);
}
private function normalizeFileTypes(array $fileTypes): array
{
return array_map(function (string $fileType) {
if (substr($fileType, 0, 1) !== '.') {
$fileType = '.' . $fileType;
}
return $fileType;
}, $fileTypes);
}
}