Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
server.php
1<?php
2
4
5class Server implements ServerInterface
6{
7 private const SCHEME_SEPARATOR = '://';
8 private const PORT_SEPARATOR = ':';
9 // public const DEFAULT_PORT = 443;
10
14 protected $scheme;
18 protected $host;
22 protected $port;
26 protected $basePath;
30 protected $userName;
34 protected $password;
35
36 public function __construct($data)
37 {
38 $this->scheme = $data['SERVER_SCHEME'];
39 $this->host = $data['SERVER_HOST'];
40 $this->port = $data['SERVER_PORT'];
41 $this->basePath = $data['SERVER_PATH'];
42 $this->userName = $data['SERVER_USERNAME'];
43 $this->password = $data['SERVER_PASSWORD'];
44 }
45
46 public function getHost(): string
47 {
48 return $this->host;
49 }
50
51 public function getScheme(): string
52 {
53 return $this->scheme;
54 }
55
56 public function getPort(): string
57 {
58 return $this->port;
59 }
60
61 public function getBasePath(): string
62 {
63 return $this->basePath;
64 }
65
66 public function getUserName(): ?string
67 {
68 return $this->userName;
69 }
70
71 public function getPassword(): ?string
72 {
73 return $this->password;
74 }
75
76 public function setPassword($password): Server
77 {
78 $this->password = $password;
79
80 return $this;
81 }
82
83 public function getFullPath(): string
84 {
85 return $this->getScheme()
86 . self::SCHEME_SEPARATOR
87 . $this->getHost()
88 . self::PORT_SEPARATOR
89 . $this->getPort()
90 . $this->getBasePath()
91 ;
92 }
93
99 public static function getEncodePath(string $path): string
100 {
101 return urlencode($path);
102 }
103
109 public static function mapUri(string $uri, array $map): string
110 {
111 return str_replace(array_keys($map), $map, $uri);
112 }
113}
static getEncodePath(string $path)
Definition server.php:99
static mapUri(string $uri, array $map)
Definition server.php:109