Skip to content

Commit d45d645

Browse files
committed
DateTimeUtil
1 parent 58729ba commit d45d645

File tree

7 files changed

+113
-9
lines changed

7 files changed

+113
-9
lines changed

src/Util/AppContainer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
namespace doganoo\PHPUtil\Util;
2727

28-
2928
use doganoo\PHPAlgorithms\Datastructure\Lists\Node;
3029
use doganoo\PHPAlgorithms\Datastructure\Maps\HashMap;
3130

src/Util/ArrayUtil.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
*/
3333
final class ArrayUtil {
3434
/**
35-
* ArrayUtil constructor.
35+
* prevent from instantiation
36+
* StringUtil constructor.
3637
*/
3738
private function __construct() {
3839
}

src/Util/ClassUtil.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
*
3131
* @package doganoo\PHPUtil\Util
3232
*/
33-
class ClassUtil {
33+
final class ClassUtil {
3434

3535
/**
36-
* ClassUtil constructor.
36+
* prevent from instantiation
37+
* StringUtil constructor.
3738
*/
3839
private function __construct() {
3940
}

src/Util/DateTimeUtil.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* MIT License
4+
*
5+
* Copyright (c) 2018 Dogan Ucar, <dogan@dogan-ucar.de>
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
26+
namespace doganoo\PHPUtil\Util;
27+
28+
/**
29+
* Class DateTimeUtil
30+
*
31+
* @package doganoo\PHPUtil\Util
32+
*/
33+
final class DateTimeUtil {
34+
/**
35+
* prevent from instantiation
36+
* StringUtil constructor.
37+
*/
38+
private function __construct() {
39+
}
40+
41+
/**
42+
* returns the actual unix timestamp
43+
*
44+
* @return int
45+
*/
46+
public static function getUnixTimestamp(): int {
47+
return (new \DateTime())->getTimestamp();
48+
}
49+
}

src/Util/HTMLUtil.php

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,82 @@
11
<?php
2-
2+
/**
3+
* MIT License
4+
*
5+
* Copyright (c) 2018 Dogan Ucar, <dogan@dogan-ucar.de>
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
325

426
namespace doganoo\PHPUtil\Util;
527

6-
28+
/**
29+
* Class HTMLUtil
30+
*
31+
* @package doganoo\PHPUtil\Util
32+
*/
733
final class HTMLUtil {
34+
/**
35+
* prevent from instantiation
36+
* StringUtil constructor.
37+
*/
838
private function __construct() {
939
}
1040

41+
/**
42+
* @param string $url
43+
* @return string
44+
*/
1145
public static function CSSBackground(string $url): string {
1246
return "background-image: url(\"$url\");";
1347
}
1448

49+
/**
50+
* @param string $type
51+
* @param string $path
52+
* @return string
53+
*/
1554
public static function buildScriptTag(string $type, string $path): string {
1655
return "<script type='$type' src='$path' ></script >";
1756
}
1857

58+
/**
59+
* @param string $path
60+
* @return string
61+
*/
1962
public static function buildCssTag(string $path): string {
2063
return "<link rel = 'stylesheet' href = '$path' >";
2164
}
2265

66+
/**
67+
* @param string $type
68+
* @param string $value
69+
* @return string
70+
*/
2371
public static function getField(string $type, string $value): string {
2472
return " $type = '$value' ";
2573
}
2674

75+
/**
76+
* @param string $link
77+
* @param bool $newTab
78+
* @return string
79+
*/
2780
public static function getHyperReference(string $link, bool $newTab = false): string {
2881
$newTabString = $newTab ? "target='_blank'" : "";
2982
return "<a $newTabString href='$link'>";

src/Util/NumberUtil.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
*
3131
* @package doganoo\PHPUtil\Util
3232
*/
33-
class NumberUtil {
33+
final class NumberUtil {
3434
/**
35-
* NumberUtil constructor.
35+
* prevent from instantiation
36+
* StringUtil constructor.
3637
*/
3738
private function __construct() {
3839
}

src/Util/StringUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
* @package doganoo\PHPUtil\Util
3232
*/
33-
class StringUtil {
33+
final class StringUtil {
3434
/**
3535
* prevent from instantiation
3636
* StringUtil constructor.

0 commit comments

Comments
 (0)