Skip to content

Commit f23091b

Browse files
authored
Merge pull request #8 from DirectoryTree/v3
V3
2 parents 5fbdf40 + 032dc7f commit f23091b

File tree

9 files changed

+45
-83
lines changed

9 files changed

+45
-83
lines changed

.github/workflows/run-tests.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,14 @@ on:
88

99
jobs:
1010
run-tests:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
php: [8.1, 8.0, 7.4, 7.3, 7.2]
16-
lumen: [9.*, 8.*, 7.*, 6.*, 5.8.*]
15+
os: [ubuntu-latest]
16+
php: [8.2, 8.1]
17+
lumen: [10.*, 9.*, 8.*]
1718
dependency-version: [prefer-stable]
18-
exclude:
19-
- lumen: 9.*
20-
php: 7.4
21-
- lumen: 9.*
22-
php: 7.3
23-
- lumen: 9.*
24-
php: 7.2
25-
- lumen: 8.*
26-
php: 7.2
27-
- lumen: 7.*
28-
php: 8.1
29-
- lumen: 7.*
30-
php: 8.0
31-
- lumen: 6.*
32-
php: 8.1
33-
- lumen: 6.*
34-
php: 8.0
35-
- lumen: 5.8.*
36-
php: 8.1
37-
- lumen: 5.8.*
38-
php: 8.0
3919

4020
name: P${{ matrix.php }} - L${{ matrix.lumen }} - ${{ matrix.dependency-version }}
4121

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
composer.lock
22
vendor/
3+
.phpunit.result.cache

.scrutinizer.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ filter:
44
build:
55
nodes:
66
analysis:
7+
environment:
8+
php:
9+
version: 8.1
710
tests:
811
override:
912
- command: php-scrutinizer-run

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"license": "MIT",
66
"type": "project",
77
"require": {
8-
"php": ">=7.2",
9-
"ext-ldap": "*",
10-
"directorytree/ldaprecord-laravel": "^v2.1.1",
11-
"laravel/lumen-framework": "^5.6|^6.0|^7.0|^8.0|^9.0|^10.0"
8+
"php": ">=8.1",
9+
"directorytree/ldaprecord-laravel": "^v3.0",
10+
"laravel/lumen-framework": "^8.0|^9.0|^v10.0"
1211
},
1312
"require-dev": {
1413
"mockery/mockery": "^1.3.1",
15-
"phpunit/phpunit": "^8.5"
14+
"phpunit/phpunit": "^8.5",
15+
"laravel/pint": "^1.10"
1616
},
1717
"archive": {
1818
"exclude": ["/tests"]

src/LdapAuthServiceProvider.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,17 @@
33
namespace LdapRecord\Lumen;
44

55
use Illuminate\Support\Facades\Auth;
6-
use Illuminate\Support\Facades\Event;
76
use LdapRecord\Laravel\LdapAuthServiceProvider as BaseServiceProvider;
87

98
class LdapAuthServiceProvider extends BaseServiceProvider
109
{
1110
/**
1211
* {@inheritDoc}
1312
*/
14-
protected function registerAuthProvider()
13+
protected function registerAuthProvider(): void
1514
{
1615
if (! is_null(Auth::getFacadeRoot())) {
1716
parent::registerAuthProvider();
1817
}
19-
20-
return $this;
21-
}
22-
23-
/**
24-
* {@inheritDoc}
25-
*/
26-
protected function registerEventListeners()
27-
{
28-
if (! is_null(Event::getFacadeRoot())) {
29-
parent::registerEventListeners();
30-
}
31-
32-
return $this;
3318
}
3419
}

src/LdapServiceProvider.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,36 @@
22

33
namespace LdapRecord\Lumen;
44

5+
use Illuminate\Support\Facades\Event;
56
use LdapRecord\Laravel\LdapServiceProvider as BaseServiceProvider;
67

78
class LdapServiceProvider extends BaseServiceProvider
89
{
910
/**
1011
* {@inheritDoc}
1112
*/
12-
protected function registerConfiguration()
13+
protected function registerConfiguration(): void
1314
{
1415
$this->app->configure('ldap');
15-
16-
return $this;
1716
}
1817

1918
/**
2019
* {@inheritDoc}
2120
*/
22-
protected function registerCommands()
21+
protected function registerCommands(): void
2322
{
2423
parent::registerCommands();
2524

2625
$this->commands([MakeLdapConfig::class]);
26+
}
2727

28-
return $this;
28+
/**
29+
* {@inheritDoc}
30+
*/
31+
protected function registerEventListeners(): void
32+
{
33+
if (! is_null(Event::getFacadeRoot())) {
34+
parent::registerEventListeners();
35+
}
2936
}
3037
}

src/MakeLdapConfig.php

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ class MakeLdapConfig extends Command
99
{
1010
/**
1111
* The filesystem instance.
12-
*
13-
* @var \Illuminate\Filesystem\Filesystem
1412
*/
15-
protected $files;
13+
protected Filesystem $files;
1614

1715
/**
1816
* The console command name.
1917
*
2018
* @var string
2119
*/
22-
protected $name = 'make:ldap-config';
20+
protected $name = 'ldap:make:config';
2321

2422
/**
2523
* The console command description.
@@ -30,9 +28,6 @@ class MakeLdapConfig extends Command
3028

3129
/**
3230
* Create a new controller creator command instance.
33-
*
34-
* @param Filesystem $files
35-
* @return void
3631
*/
3732
public function __construct(Filesystem $files)
3833
{
@@ -44,18 +39,22 @@ public function __construct(Filesystem $files)
4439
/**
4540
* Create the LDAP configuration file.
4641
*/
47-
public function handle()
42+
public function handle(): int
4843
{
4944
if (! $this->files->exists($stubPath = $this->getStubPath())) {
50-
return $this->error("Unable to retrieve LDAP configuration stub file from path [$stubPath]");
45+
$this->error("Unable to retrieve LDAP configuration stub file from path [$stubPath]");
46+
47+
return static::FAILURE;
5148
}
5249

5350
$publishPath = $this->getLdapConfigPath(
5451
$configPath = $this->getConfigPath()
5552
);
5653

5754
if ($this->alreadyExists($publishPath)) {
58-
return $this->error("LDAP configuration file already exists at path [$publishPath]");
55+
$this->error("LDAP configuration file already exists at path [$publishPath]");
56+
57+
return static::INVALID;
5958
}
6059

6160
if (! $this->alreadyExists($configPath)) {
@@ -65,67 +64,54 @@ public function handle()
6564
$this->files->put($publishPath, $this->getContents($stubPath));
6665

6766
$this->info("Successfully created LDAP configuration file at path [$publishPath]");
67+
68+
return static::SUCCESS;
6869
}
6970

7071
/**
7172
* Determine if the given file / folder already exists.
72-
*
73-
* @param string $path
74-
* @return bool
7573
*/
76-
protected function alreadyExists($path)
74+
protected function alreadyExists(string $path): bool
7775
{
7876
return $this->files->exists($path);
7977
}
8078

8179
/**
8280
* Make the given directory path.
83-
*
84-
* @param string $path
8581
*/
86-
protected function makeDirectory($path)
82+
protected function makeDirectory(string $path): void
8783
{
8884
$this->files->makeDirectory($path);
8985
}
9086

9187
/**
9288
* Get the contents of the given file.
93-
*
94-
* @param string $path
95-
* @return string
9689
*/
97-
protected function getContents($path)
90+
protected function getContents(string $path): string
9891
{
9992
return $this->files->get($path);
10093
}
10194

10295
/**
10396
* Get the LDAP configuration file stub.
104-
*
105-
* @return string
10697
*/
107-
protected function getStubPath()
98+
protected function getStubPath(): string
10899
{
109100
return base_path(implode(DIRECTORY_SEPARATOR, ['vendor', 'directorytree', 'ldaprecord-laravel', 'config', 'ldap.php']));
110101
}
111102

112103
/**
113104
* Get the configuration folder path.
114-
*
115-
* @return string
116105
*/
117-
public function getConfigPath()
106+
public function getConfigPath(): string
118107
{
119108
return base_path('config');
120109
}
121110

122111
/**
123112
* Get the full LDAP configuration file path.
124-
*
125-
* @param string $configPath
126-
* @return string
127113
*/
128-
protected function getLdapConfigPath($configPath)
114+
protected function getLdapConfigPath(string $configPath): string
129115
{
130116
return $configPath.DIRECTORY_SEPARATOR.'ldap.php';
131117
}

tests/LdapServiceProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424

2525
public function test_connections_are_auto_loaded()
2626
{
27-
$this->assertIsArray($connections = Container::getInstance()->all());
27+
$this->assertIsArray($connections = Container::getInstance()->getConnections());
2828
$this->assertCount(1, $connections);
2929

3030
$this->assertInstanceOf(Connection::class, $default = $connections['default']);

tests/MakeLdapConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function configFileFolder()
4141

4242
public function test_configuration_file_can_be_published()
4343
{
44-
$this->artisan('make:ldap-config');
44+
$this->artisan('ldap:make:config');
4545

4646
$this->assertTrue(file_exists($this->configFilePath()));
4747
$this->assertTrue(file_exists($this->configFileFolder()));

0 commit comments

Comments
 (0)