Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.

Commit d987f80

Browse files
committed
some bug fixed
1 parent 9d7d66a commit d987f80

File tree

9 files changed

+601
-409
lines changed

9 files changed

+601
-409
lines changed

examples/logger.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
require __DIR__ . '/s-autoload.php';
1212

1313
$lgr = LiteLogger::make([
14+
'name' => 'test',
1415
'splitType' => 'hour',
15-
'basePath' => __DIR__,
16-
], 'test');
16+
'basePath' => __DIR__ . '/tmp',
17+
]);
1718

1819
$lgr->trace('a traced message');
1920
$lgr->debug('a debug message', [
@@ -26,6 +27,6 @@
2627
$lgr->error('a error message');
2728
$lgr->ex(new \RuntimeException('a exception message'));
2829

29-
//$lgr->flush();
30+
$lgr->flush();
3031

3132
print_r($lgr);

examples/s-autoload.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
date_default_timezone_set('Asia/Shanghai');
1212

1313
require dirname(__DIR__) . '/src/functions.php';
14-
require dirname(__DIR__) . '/src/some_exception.php';
14+
require dirname(__DIR__) . '/src/exceptions.php';
1515

1616
spl_autoload_register(function($class)
1717
{
1818
$inhereDir = dirname(__DIR__, 2);
19+
$vendorDir = dirname(__DIR__, 3);
1920
$map = [
2021
'Inhere\Library\examples\\' => __DIR__,
2122
'Inhere\Library\\' => dirname(__DIR__) . '/src',
22-
'inhere\queue\\' => $inhereDir . '/queue/src',
23+
'Inhere\Queue\\' => $inhereDir . '/queue/src',
24+
'Psr\Log\\' => $vendorDir . '/psr/log/Psr/Log',
2325
];
2426

2527
foreach ($map as $np => $dir) {

src/Components/DataProxy.php

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: inhere
5+
* Date: 2017/10/18
6+
* Time: 下午9:39
7+
*/
8+
9+
namespace Inhere\Library\Components;
10+
11+
/**
12+
* Class DataProxy
13+
* @package Inhere\Library\Components
14+
*/
15+
class DataProxy
16+
{
17+
/**
18+
* proxy list
19+
* @var array
20+
* [
21+
* // 'name' => 'handler',
22+
* 'getArticleList' => [ArticleDao::class, 'getArticleList'],
23+
* ]
24+
*/
25+
protected $proxies = [];
26+
27+
public function __construct(array $proxies = [])
28+
{
29+
$this->proxies = $proxies;
30+
}
31+
32+
/**
33+
* @param string $method
34+
* @param array $args
35+
* @return mixed
36+
*/
37+
public function __call($method, array $args)
38+
{
39+
return $this->call($method, $args);
40+
}
41+
42+
/**
43+
* @param string $name
44+
* @param array $args
45+
* @return mixed
46+
*/
47+
public function call(string $name, array $args)
48+
{
49+
if ($this->hasName($name)) {
50+
$handler = $this->proxies[$name];
51+
return $handler(...$args);
52+
}
53+
54+
throw new \RuntimeException("Called method $name is not exists.");
55+
}
56+
57+
/**
58+
* @param string $name
59+
* @param callable $callback
60+
*/
61+
public function add(string $name, callable $callback)
62+
{
63+
if (!isset($this->proxies[$name])) {
64+
$this->proxies[$name] = $callback;
65+
}
66+
}
67+
68+
/**
69+
* @param string $name
70+
* @param callable $callback
71+
*/
72+
public function addProxy(string $name, callable $callback)
73+
{
74+
if (!isset($this->proxies[$name])) {
75+
$this->proxies[$name] = $callback;
76+
}
77+
}
78+
79+
/**
80+
* @param string $name
81+
* @param callable $callback
82+
*/
83+
public function setProxy(string $name, callable $callback)
84+
{
85+
if (!isset($this->proxies[$name])) {
86+
$this->proxies[$name] = $callback;
87+
}
88+
}
89+
90+
/**
91+
* @param string $name
92+
* @return bool
93+
*/
94+
public function hasName(string $name)
95+
{
96+
return isset($this->proxies[$name]);
97+
}
98+
99+
/**
100+
* @param array $proxies
101+
*/
102+
public function addProxies(array $proxies)
103+
{
104+
foreach ($proxies as $name => $callback) {
105+
$this->addProxy($name, $callback);
106+
}
107+
}
108+
109+
/**
110+
* @return array
111+
*/
112+
public function getProxies(): array
113+
{
114+
return $this->proxies;
115+
}
116+
117+
/**
118+
* @param array $proxies
119+
*/
120+
public function setProxies(array $proxies)
121+
{
122+
$this->proxies = $proxies;
123+
}
124+
}
125+

src/Components/Language.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class Language extends StdObject implements \ArrayAccess, \Countable, \IteratorA
100100

101101
const DEFAULT_FILE_KEY = '__default';
102102

103-
104103
/**
105104
* {@inheritDoc}
106105
*/
@@ -209,7 +208,6 @@ public function has($key)
209208
/**
210209
* @param string $key
211210
* @return mixed
212-
* @throws \Inhere\Exceptions\NotFoundException
213211
*/
214212
protected function findTranslationText($key)
215213
{

0 commit comments

Comments
 (0)