Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Commit a86011e

Browse files
Merge branch 'develop'
2 parents 1f45315 + 7932f6a commit a86011e

File tree

7 files changed

+66
-21
lines changed

7 files changed

+66
-21
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Some of features:
1111
- Readable and centralized Theme Configs
1212
- Enhanced [Templating](https://en.wikibooks.org/wiki/PHP_Programming/Why_Templating) with support for passing data
1313

14+
### Documentation
15+
16+
Comprehensive documentation is available at http://labs.tonik.pl/theme/
17+
1418
## Contributing
1519

1620
Great that you are considering supporting the project. You have a lot of ways to help us grow. We appreciate all contributions, even the smallest.
@@ -23,4 +27,4 @@ Great that you are considering supporting the project. You have a lot of ways to
2327

2428
## License
2529

26-
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
30+
Licensed under the [MIT license](http://opensource.org/licenses/MIT).

src/Gin/Asset/Asset.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
namespace Tonik\Gin\Asset;
44

5-
use Tonik\Gin\Foundation\Config;
5+
use Tonik\Gin\Contract\ConfigInterface;
66
use Tonik\Gin\Foundation\Exception\FileNotFoundException;
7-
use Tonik\Gin\Foundation\Theme;
87

98
class Asset
109
{
1110
/**
1211
* Theme config instance.
1312
*
14-
* @var \Tonik\Gin\Foundation\Config
13+
* @var \Tonik\Gin\Foundation\ConfigInterface
1514
*/
1615
protected $config;
1716

@@ -25,9 +24,9 @@ class Asset
2524
/**
2625
* Construct asset.
2726
*
28-
* @param \Tonik\Gin\Foundation\Config $config
27+
* @param \Tonik\Gin\Foundation\ConfigInterface $config
2928
*/
30-
public function __construct(Config $config)
29+
public function __construct(ConfigInterface $config)
3130
{
3231
$this->config = $config;
3332
}

src/Gin/Contract/ConfigInterface.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Tonik\Gin\Contract;
4+
5+
interface ConfigInterface
6+
{
7+
/**
8+
* Get all of the configuration items for the application.
9+
*
10+
* @return array
11+
*/
12+
public function all();
13+
14+
/**
15+
* Get the specified configuration value.
16+
*
17+
* @param string $key
18+
* @param mixed $default
19+
*
20+
* @return mixed
21+
*/
22+
public function get($key, $default);
23+
24+
/**
25+
* Set a given configuration value.
26+
*
27+
* @param array|string $key
28+
* @param mixed $value
29+
*
30+
* @return void
31+
*/
32+
public function set($key, $value);
33+
34+
/**
35+
* Determine if the given configuration value exists.
36+
*
37+
* @param string $key
38+
*
39+
* @return bool
40+
*/
41+
public function has($key);
42+
}

src/Gin/Foundation/Autoloader.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
namespace Tonik\Gin\Foundation;
44

5+
use Tonik\Gin\Contract\ConfigInterface;
56
use Tonik\Gin\Foundation\Exception\FileNotFoundException;
6-
use Tonik\Gin\Foundation\Theme;
77

88
class Autoloader
99
{
1010
/**
1111
* Theme config instance.
1212
*
13-
* @var array
13+
* @var \Tonik\Gin\Contract\ConfigInterface
1414
*/
1515
protected $config;
1616

1717
/**
1818
* Construct autoloader.
1919
*
20-
* @param \Tonik\Gin\Foundation\Theme $theme
20+
* @param \Tonik\Gin\Contract\ConfigInterface $config
2121
*/
22-
public function __construct($config)
22+
public function __construct(ConfigInterface $config)
2323
{
2424
$this->config = $config;
2525
}

src/Gin/Foundation/Config.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace Tonik\Gin\Foundation;
44

55
use ArrayAccess;
6+
use Tonik\Gin\Contract\ConfigInterface;
67

7-
class Config implements ArrayAccess
8+
class Config implements ConfigInterface, ArrayAccess
89
{
910
/**
1011
* All of the configuration items.

src/Gin/Foundation/Theme.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Tonik\Gin\Foundation;
44

5-
use Closure;
65
use ArrayAccess;
6+
use Closure;
77
use Tonik\Gin\Foundation\Exception\BindingResolutionException;
88

99
class Theme extends Singleton implements ArrayAccess
@@ -92,7 +92,7 @@ public function get($key, array $parameters = [])
9292
if (isset($this->services[$key])) {
9393
// Resolve service jf we don't have
9494
// a deposit for this service.
95-
if (! isset($this->deposit[$key])) {
95+
if ( ! isset($this->deposit[$key])) {
9696
$this->deposit[$key] = $this->resolve($this->services[$key], $parameters);
9797
}
9898

@@ -148,7 +148,7 @@ public function offsetGet($key)
148148
*/
149149
public function offsetSet($key, $service)
150150
{
151-
if (! is_callable($service)) {
151+
if ( ! is_callable($service)) {
152152
throw new BindingResolutionException("Service definition [{$service}] is not an instance of Closure");
153153
}
154154

src/Gin/Template/Template.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
namespace Tonik\Gin\Template;
44

5-
use Tonik\Gin\Foundation\Config;
5+
use Tonik\Gin\Contract\ConfigInterface;
66
use Tonik\Gin\Foundation\Exception\FileNotFoundException;
7-
use Tonik\Gin\Foundation\Theme;
87

98
class Template
109
{
1110
/**
1211
* Theme config instance.
1312
*
14-
* @var array
13+
* @var \Tonik\Gin\Contract\ConfigInterface
1514
*/
1615
protected $config;
1716

@@ -25,9 +24,9 @@ class Template
2524
/**
2625
* Construct template.
2726
*
28-
* @param \Tonik\Gin\Foundation\Config $config
27+
* @param \Tonik\Gin\Contract\ConfigInterface $config
2928
*/
30-
public function __construct(Config $config)
29+
public function __construct(ConfigInterface $config)
3130
{
3231
$this->config = $config;
3332
}
@@ -149,13 +148,13 @@ public function isNamed()
149148
{
150149
// If file is not array, then template
151150
// is not named for sure.
152-
if (! is_array($this->file)) {
151+
if ( ! is_array($this->file)) {
153152
return false;
154153
}
155154

156155
// Return false if template is named,
157156
// but name is bool or null.
158-
if (isset($this->file[1]) && is_bool($this->file[1]) || is_null($this->file[1])) {
157+
if (isset($this->file[1]) && is_bool($this->file[1]) || null === $this->file[1]) {
159158
return false;
160159
}
161160

0 commit comments

Comments
 (0)