forked from icecoder/ICEcoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURL.php
More file actions
35 lines (30 loc) · 1.13 KB
/
URL.php
File metadata and controls
35 lines (30 loc) · 1.13 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
<?php declare(strict_types=1);
namespace ICEcoder;
class URL
{
private $remoteFile;
/**
* URL constructor.
* @param $remoteFile
*/
public function __construct($remoteFile)
{
$this->remoteFile = $remoteFile;
}
/**
* @param string $lineEnding
* @param int $lineNumber
* @return string
*/
public function load($lineEnding = "\n", $lineNumber = 1): string
{
// replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
$this->remoteFile = str_replace("\r\n", $lineEnding, $this->remoteFile);
$this->remoteFile = str_replace("\r", $lineEnding, $this->remoteFile);
$this->remoteFile = str_replace("\n", $lineEnding, $this->remoteFile);
$doNext = 'ICEcoder.newTab(false);';
$doNext .= 'ICEcoder.getcMInstance().setValue(\'' . str_replace("\r", "", str_replace("\t", "\\\\t", str_replace("\n", "\\\\n", str_replace("'", "\\\\'", str_replace("\\", "\\\\", preg_quote($this->remoteFile)))))) . '\');';
$doNext .= 'ICEcoder.goToLine(' . $lineNumber . ');';
return $doNext;
}
}