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

Commit e6d7d1d

Browse files
author
Lucas Michot
committed
Set all docblocks.
1 parent f04dc16 commit e6d7d1d

File tree

5 files changed

+62
-12
lines changed

5 files changed

+62
-12
lines changed

src/Credentials.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,42 @@ class Credentials
1010
{
1111
const CONFIG_PREFIX = '___credentials_';
1212

13-
/** @var Encrypter */
13+
/**
14+
* The encrypter.
15+
*
16+
* @var \Illuminate\Contracts\Encryption\Encrypter
17+
*/
1418
private $encrypter;
1519

16-
/** @var array */
20+
/**
21+
* The decrpyted values array.
22+
*
23+
* @var array
24+
*/
1725
private $decrypted;
1826

1927
/**
2028
* Create a new Credentials Instance.
21-
* @param Encrypter $encrypter
29+
*
30+
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
31+
* @return void
2232
*/
2333
public function __construct(Encrypter $encrypter)
2434
{
2535
$this->encrypter = $encrypter;
2636
}
2737

2838
/**
39+
* Load the file.
40+
*
2941
* @param string $filename
3042
* @return array
3143
*/
3244
public function load(string $filename)
3345
{
3446
if (!file_exists($filename)) {
3547
$this->decrypted = [];
48+
3649
return $this->decrypted;
3750
}
3851

@@ -48,6 +61,7 @@ public function load(string $filename)
4861
*
4962
* @param array $data
5063
* @param string $filename
64+
* @return void
5165
*/
5266
public function store(array $data, string $filename)
5367
{
@@ -59,6 +73,8 @@ public function store(array $data, string $filename)
5973
}
6074

6175
/**
76+
* Get an encrypter value.
77+
*
6278
* @param string $key
6379
* @param null $default
6480
* @return mixed

src/CredentialsServiceProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
class CredentialsServiceProvider extends ServiceProvider
1010
{
11-
1211
/**
1312
* Bootstrap the application services.
13+
*
14+
* @return void
1415
*/
1516
public function boot()
1617
{
@@ -26,6 +27,11 @@ public function boot()
2627
}
2728
}
2829

30+
/**
31+
* Fix the configuration.
32+
*
33+
* @return void
34+
*/
2935
protected function fixConfig()
3036
{
3137
collect(array_dot(config()->all()))->filter(function ($item) {
@@ -39,6 +45,8 @@ protected function fixConfig()
3945

4046
/**
4147
* Register the application services.
48+
*
49+
* @return void
4250
*/
4351
public function register()
4452
{
@@ -52,6 +60,7 @@ public function register()
5260
}
5361

5462
$encrypter = new Encrypter($key, config('credentials.cipher'));
63+
5564
return new Credentials($encrypter);
5665
});
5766

src/EditCredentialsCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Console\Command;
66
use Symfony\Component\Process\Process;
77
use BeyondCode\Credentials\Exceptions\InvalidJSON;
8-
use Symfony\Component\Process\Exception\ProcessFailedException;
98

109
class EditCredentialsCommand extends Command
1110
{
@@ -23,6 +22,12 @@ class EditCredentialsCommand extends Command
2322
*/
2423
protected $description = 'Encrypt and edit existing credentials. They will be decrypted after saving.';
2524

25+
/**
26+
* The command handler.
27+
*
28+
* @param \BeyondCode\Credentials\Credentials $credentials
29+
* @return void
30+
*/
2631
public function handle(Credentials $credentials)
2732
{
2833
$filename = config('credentials.file');
@@ -51,4 +56,4 @@ public function handle(Credentials $credentials)
5156

5257
$this->info('Successfully updated credentials.');
5358
}
54-
}
59+
}

src/Exceptions/InvalidJSON.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,23 @@
66

77
class InvalidJSON extends Exception
88
{
9+
/**
10+
* Create a new InvalidJson exception instance.
11+
*
12+
* @param int $error
13+
* @return $this
14+
*/
915
public static function create($error)
1016
{
1117
return new static("Unable to parse credential JSON ".self::getErrorMessage($error));
1218
}
1319

20+
/**
21+
* Get the error message.
22+
*
23+
* @param int $error
24+
* @return string
25+
*/
1426
private static function getErrorMessage($error)
1527
{
1628
switch ($error) {

src/helpers.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22

33
use BeyondCode\Credentials\Credentials;
44

5-
if (!function_exists('credentials')) {
6-
function credentials(string $key, $default = null) {
5+
if (! function_exists('credentials')) {
6+
/**
7+
* Get a an encrypted value.
8+
*
9+
* @param string $key
10+
* @param null $default
11+
* @return mixed
12+
*/
13+
function credentials(string $key, $default = null)
14+
{
715
$filename = config('credentials.file');
816

917
try {
10-
$credentials = app(Credentials::class);
11-
$credentials->load($filename);
18+
$credentials = app(Credentials::class);
19+
$credentials->load($filename);
1220

13-
return $credentials->get($key, $default);
21+
return $credentials->get($key, $default);
1422
} catch (ReflectionException $e) {
15-
return Credentials::CONFIG_PREFIX.$key;
23+
return Credentials::CONFIG_PREFIX.$key;
1624
}
1725
}
1826
}

0 commit comments

Comments
 (0)