Skip to content

Commit c7985be

Browse files
committed
Added Casbin 2.0 support
1 parent 5283e51 commit c7985be

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":187:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:2:{s:55:"Casbin\Bridge\Logger\Tests\LoggerTest::testEnableLogger";d:0.071;s:56:"Casbin\Bridge\Logger\Tests\LoggerTest::testDisableLogger";d:0.002;}}}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
],
1818
"license": "Apache-2.0",
1919
"require": {
20-
"casbin/casbin": "^1.0",
20+
"casbin/casbin": "^2.0",
2121
"psr/log": "^1.1"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "~5.7|~6.0|~7.0",
24+
"phpunit/phpunit": "~7.0|~8.0",
2525
"mockery/mockery": "^1.2",
2626
"php-coveralls/php-coveralls": "^2.1"
2727
},

src/LoggerBridge.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Casbin\Bridge\Logger;
46

5-
use Casbin\Log\Logger as LoggerContract;
7+
use Casbin\Log\Logger;
68
use Psr\Log\LoggerInterface;
79

8-
class LoggerBridge implements LoggerContract
10+
class LoggerBridge implements Logger
911
{
12+
/**
13+
* Whether to enable logging.
14+
*
15+
* @var bool
16+
*/
1017
public $enable = false;
1118

1219
/**
@@ -40,7 +47,7 @@ public function __construct(LoggerInterface $logger, $defaultLevel = 'info')
4047
*
4148
* @param bool $enable
4249
*/
43-
public function enableLog($enable)
50+
public function enableLog(bool $enable): void
4451
{
4552
$this->enable = $enable;
4653
}
@@ -50,7 +57,7 @@ public function enableLog($enable)
5057
*
5158
* @return bool
5259
*/
53-
public function isEnabled()
60+
public function isEnabled(): bool
5461
{
5562
return $this->enable;
5663
}
@@ -59,10 +66,8 @@ public function isEnabled()
5966
* formats using the default formats for its operands and logs the message.
6067
*
6168
* @param mixed ...$v
62-
*
63-
* @return mixed
6469
*/
65-
public function write(...$v)
70+
public function write(...$v): void
6671
{
6772
if (!$this->enable) {
6873
return;
@@ -84,12 +89,10 @@ public function write(...$v)
8489
/**
8590
* formats according to a format specifier and logs the message.
8691
*
87-
* @param $format
88-
* @param mixed ...$v
89-
*
90-
* @return mixed
92+
* @param string $format
93+
* @param mixed ...$v
9194
*/
92-
public function writef($format, ...$v)
95+
public function writef(string $format, ...$v): void
9396
{
9497
if (!$this->enable) {
9598
return;

0 commit comments

Comments
 (0)