Skip to content

Commit 0c2c7f7

Browse files
committed
Added View and Configuration.
1 parent 7c19a2d commit 0c2c7f7

5 files changed

Lines changed: 98 additions & 7 deletions

File tree

src/Application/ApplicationInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace PHPCensor\Common\Application;
66

7+
use PHPCensor\Common\ConfigurationInterface;
8+
79
/**
810
* @package PHP Censor
911
* @subpackage Common Library
@@ -15,9 +17,9 @@ interface ApplicationInterface
1517
/**
1618
* Returns system (application) configuration.
1719
*
18-
* @return array
20+
* @return ConfigurationInterface
1921
*/
20-
public function getConfig(): array;
22+
public function getConfiguration(): ConfigurationInterface;
2123

2224
/**
2325
* Example: /var/www/php-censor.localhost/

src/ConfigurationInterface.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace PHPCensor\Common;
6+
7+
/**
8+
* @package PHP Censor
9+
* @subpackage Common Library
10+
*
11+
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
12+
*/
13+
interface ConfigurationInterface extends ParameterBagInterface
14+
{
15+
}

src/VariableInterpolator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public function interpolate(string $string): string
5454
*/
5555
private function realtimeInterpolate(string $string): string
5656
{
57-
$string = \str_replace('%CURRENT_DATE%', \date('Y-m-d'), $string);
58-
$string = \str_replace('%CURRENT_TIME%', \date('H-i-s'), $string);
59-
$string = \str_replace('%CURRENT_DATETIME%', \date('Y-m-d_H-i-s'), $string);
60-
61-
return $string;
57+
return \str_replace(
58+
['%CURRENT_DATE%', '%CURRENT_TIME%', '%CURRENT_DATETIME%'],
59+
[\date('Y-m-d'), \date('H-i-s'), \date('Y-m-d_H-i-s')],
60+
$string
61+
);
6262
}
6363

6464
/**

src/ViewFactoryInterface.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace PHPCensor\Common;
6+
7+
use PHPCensor\Common\Exception\Exception;
8+
9+
/**
10+
* @package PHP Censor
11+
* @subpackage Common Library
12+
*
13+
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
14+
*/
15+
interface ViewFactoryInterface
16+
{
17+
/**
18+
* @param string $viewPath
19+
* @param string|null $viewExtension
20+
*
21+
* @return ViewInterface
22+
*
23+
* @throws Exception
24+
*/
25+
public function createView(string $viewPath, ?string $viewExtension = null): ViewInterface;
26+
}

src/ViewInterface.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace PHPCensor\Common;
6+
7+
/**
8+
* @package PHP Censor
9+
* @subpackage Common Library
10+
*
11+
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
12+
*/
13+
interface ViewInterface
14+
{
15+
/**
16+
* @param string $key
17+
*
18+
* @return bool
19+
*/
20+
public function hasVariable(string $key): bool;
21+
22+
/**
23+
* @param string $key
24+
*
25+
* @return mixed
26+
*/
27+
public function getVariable(string $key);
28+
29+
/**
30+
* @param string $key
31+
* @param mixed $value
32+
*
33+
* @return bool
34+
*/
35+
public function setVariable(string $key, $value): bool;
36+
37+
/**
38+
* @param array $value
39+
*
40+
* @return bool
41+
*/
42+
public function setVariables(array $value): bool;
43+
44+
/**
45+
* @return string
46+
*/
47+
public function render(): string;
48+
}

0 commit comments

Comments
 (0)