Merge "StringUtils: Add a utility for checking if a string is a valid regex"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderFilePath.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 /**
22 * An object to represent a path to a JavaScript/CSS file, along with a remote
23 * and local base path, for use with ResourceLoaderFileModule.
24 *
25 * @ingroup ResourceLoader
26 * @since 1.17
27 */
28 class ResourceLoaderFilePath {
29
30 /** @var string Local base path */
31 protected $localBasePath;
32
33 /** @var string Remote base path */
34 protected $remoteBasePath;
35
36 /**
37 * @var string Path to the file
38 */
39 protected $path;
40
41 /**
42 * @param string $path Path to the file.
43 * @param string $localBasePath Base path to prepend when generating a local path.
44 * @param string $remoteBasePath Base path to prepend when generating a remote path.
45 */
46 public function __construct( $path, $localBasePath, $remoteBasePath ) {
47 $this->path = $path;
48 $this->localBasePath = $localBasePath;
49 $this->remoteBasePath = $remoteBasePath;
50 }
51
52 /**
53 * @return string
54 */
55 public function getLocalPath() {
56 return "{$this->localBasePath}/{$this->path}";
57 }
58
59 /**
60 * @return string
61 */
62 public function getRemotePath() {
63 return "{$this->remoteBasePath}/{$this->path}";
64 }
65
66 /**
67 * @return string
68 */
69 public function getLocalBasePath() {
70 return $this->localBasePath;
71 }
72
73 /**
74 * @return string
75 */
76 public function getRemoteBasePath() {
77 return $this->remoteBasePath;
78 }
79
80 /**
81 * @return string
82 */
83 public function getPath() {
84 return $this->path;
85 }
86 }