Skip to content

Commit bda5c1d

Browse files
committed
URLFriendly
1 parent c99b570 commit bda5c1d

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

berry/mysql/MySQLCommandParameter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
class MySQLCommandParameter
44
{
55

6-
public $Index;
6+
public int $Index;
77
public $Value;
8-
public $Type;
8+
public string $Type;
99
public $Length;
1010

11-
public function __construct($paramIndex, $value, $type, $length = NULL)
11+
public function __construct(int $paramIndex, $value, string $type, $length = NULL)
1212
{
1313
$this->Index = $paramIndex;
1414
$this->Value = $value;

berry/mysql/MySQLCommandParameters.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct()
1515
* @param type $parameter
1616
* @param type $type
1717
*/
18-
private function Add($paramIndex, $value, $type, $length = NULL)
18+
private function Add(int $paramIndex, $value, $type, $length = NULL)
1919
{
2020
$parameter = new MySQLCommandParameter($paramIndex, $value, $type, $length);
2121
$this->fParameters[$paramIndex] = $parameter;
@@ -27,7 +27,7 @@ private function Add($paramIndex, $value, $type, $length = NULL)
2727
* @param type $value
2828
* @param type $length
2929
*/
30-
public function setString($paramIndex, $value, $length = NULL)
30+
public function setString(int $paramIndex, string $value, $length = NULL)
3131
{
3232
$this->Add($paramIndex, $value, "s", $length);
3333
}
@@ -38,7 +38,7 @@ public function setString($paramIndex, $value, $length = NULL)
3838
* @param type $value
3939
* @param type $length
4040
*/
41-
public function setInteger($paramIndex, $value, $length = NULL)
41+
public function setInteger(int $paramIndex, int $value, $length = NULL)
4242
{
4343
$this->Add($paramIndex, $value, "i", $length);
4444
}
@@ -49,7 +49,7 @@ public function setInteger($paramIndex, $value, $length = NULL)
4949
* @param type $value
5050
* @param type $length
5151
*/
52-
public function setDouble($paramIndex, $value, $length = NULL)
52+
public function setDouble(int $paramIndex, float $value, $length = NULL)
5353
{
5454
$this->Add($paramIndex, $value, "d", $length);
5555
}
@@ -60,7 +60,7 @@ public function setDouble($paramIndex, $value, $length = NULL)
6060
* @param type $value
6161
* @param type $length
6262
*/
63-
public function setBlob($paramIndex, $value, $length = NULL)
63+
public function setBlob(int $paramIndex, $value, $length = NULL)
6464
{
6565
$this->Add($paramIndex, $value, "b", $length);
6666
}

berry/utils/HTMLHelper.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public function __construct()
1313
* the given html string.
1414
* @param string $tag the tag to search
1515
* @param string $html is the html string to search for tag objects
16-
* @return type array with html objects
16+
* @return string array with html objects
1717
*/
18-
public function GetHTMLTags(string $tag, string $html)
18+
public function GetHTMLTags(string $tag, string $html): array
1919
{
2020
$images = array();
2121
$regexResult = array();
@@ -26,6 +26,28 @@ public function GetHTMLTags(string $tag, string $html)
2626
}
2727
return $images;
2828
}
29+
30+
/**
31+
* Converts a string to a URL friendy format
32+
* @param string $string the string to convert to url friendly
33+
* @return string
34+
*/
35+
public function URLFriendly(string $string): string
36+
{
37+
$string = str_replace('.', "", $string);
38+
$string = str_replace('!', "", $string);
39+
$string = str_replace('(', "", $string);
40+
$string = str_replace(')', "", $string);
41+
$string = str_replace(" ", "-", $string);
42+
$string = str_replace("\\", "", $string);
43+
$string = str_replace("/", "", $string);
44+
$string = str_replace('"', "", $string);
45+
$string = preg_replace("`\[.*\]`U", "", $string);
46+
$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', $string);
47+
$string = preg_replace("`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i", "\\1", $string);
48+
return strtolower(trim($string, '-'));
49+
}
50+
2951
}
3052

3153
?>

nbproject/private/private.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3+
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
4+
</project-private>

0 commit comments

Comments
 (0)