Skip to content

Commit ec55eac

Browse files
committed
📖
1 parent 5a2eef9 commit ec55eac

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

src/Crypto.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public static function sha512(string $data, bool $binary = false):string{
6464
}
6565

6666
/**
67-
* Generates a secure random string of the given $length, using the characters (8-bit byte) in the given $keyspace.
67+
* Generates a secure random string of the given `$length`, using the characters (8-bit byte) in the given `$keyspace`.
68+
*
69+
* @see \random_int() - PHP <= 8.2
70+
* @see \Random\Randomizer - PHP >= 8.3
6871
*
6972
* @noinspection PhpFullyQualifiedNameUsageInspection
7073
* @SuppressWarnings(PHPMD.MissingImport)
@@ -88,7 +91,10 @@ public static function randomString(int $length, string $keyspace = self::ASCII_
8891
}
8992

9093
/**
91-
* Creates a new cryptographically secure random encryption key (returned in hexadecimal format)
94+
* Creates a new cryptographically secure random encryption key for use with `encrypt()` and `decrypt()` (returned in hexadecimal format)
95+
*
96+
* @see \sodium_crypto_secretbox_keygen()
97+
* @see \sodium_crypto_secretbox())
9298
*
9399
* @throws \SodiumException
94100
*/
@@ -97,7 +103,7 @@ public static function createEncryptionKey():string{
97103
}
98104

99105
/**
100-
* Encrypts the given $data with $key, $format output [binary, base64, hex]
106+
* Encrypts the given `$data` with `$key`, formats the output according to `$format` [binary, base64, hex]
101107
*
102108
* @see \sodium_crypto_secretbox()
103109
* @see \sodium_bin2base64()
@@ -125,7 +131,7 @@ public static function encrypt(string $data, string $keyHex, int $format = self:
125131
}
126132

127133
/**
128-
* Decrypts the given $encrypted data with $key from $format input [binary, base64, hex]
134+
* Decrypts the given `$encrypted` data with `$key` from input formatted according to `$format` [binary, base64, hex]
129135
*
130136
* @see \sodium_crypto_secretbox_open()
131137
* @see \sodium_base642bin()

src/Directory.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,29 @@
2929
*/
3030
final class Directory{
3131

32-
/** @codeCoverageIgnore */
32+
/**
33+
* Checks whether a directory exists
34+
*
35+
* @codeCoverageIgnore
36+
*/
3337
public static function exists(string $dir):bool{
3438
return file_exists($dir) && is_dir($dir);
3539
}
3640

37-
/** @codeCoverageIgnore */
41+
/**
42+
* Checks whether the given directory is readable
43+
*
44+
* @codeCoverageIgnore
45+
*/
3846
public static function isReadable(string $dir):bool{
3947
return self::exists($dir) && is_readable($dir);
4048
}
4149

42-
/** @codeCoverageIgnore */
50+
/**
51+
* Checks whether the given directory is writable
52+
*
53+
* @codeCoverageIgnore
54+
*/
4355
public static function isWritable(string $dir):bool{
4456
return self::exists($dir) && is_writable($dir);
4557
}

src/File.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,29 @@
2828
*/
2929
final class File{
3030

31-
/** @codeCoverageIgnore */
31+
/**
32+
* Checks whether a file exists
33+
*
34+
* @codeCoverageIgnore
35+
*/
3236
public static function exists(string $file):bool{
3337
return file_exists($file) && is_file($file);
3438
}
3539

36-
/** @codeCoverageIgnore */
40+
/**
41+
* Checks whether the given file is readable
42+
*
43+
* @codeCoverageIgnore
44+
*/
3745
public static function isReadable(string $file):bool{
3846
return self::exists($file) && is_readable($file);
3947
}
4048

41-
/** @codeCoverageIgnore */
49+
/**
50+
* Checks whether the given file is writable
51+
*
52+
* @codeCoverageIgnore
53+
*/
4254
public static function isWritable(string $file):bool{
4355
return self::exists($file) && is_writable($file);
4456
}

src/Str.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ final class Str{
3939
/**
4040
* Filters an array and removes all elements that are not strings. Array keys are *not* retained.
4141
*
42-
*
4342
* @see array_filter()
4443
* @see array_values()
4544
* @see is_string()

tests/StrTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static function startsWithProvider():array{
3333
];
3434
}
3535

36+
/**
37+
* @param string[] $needles
38+
*/
3639
#[Test]
3740
#[DataProvider('startsWithProvider')]
3841
public function startsWith(array $needles, bool $ignoreCase, bool $expected):void{
@@ -52,6 +55,9 @@ public static function containsAllProvider():array{
5255
];
5356
}
5457

58+
/**
59+
* @param string[] $needles
60+
*/
5561
#[Test]
5662
#[DataProvider('containsAllProvider')]
5763
public function containsAll(array $needles, bool $ignoreCase, bool $expected):void{
@@ -71,11 +77,13 @@ public static function containsAnyProvider():array{
7177
];
7278
}
7379

80+
/**
81+
* @param string[] $needles
82+
*/
7483
#[Test]
7584
#[DataProvider('containsAnyProvider')]
7685
public function containsAny(array $needles, bool $ignoreCase, bool $expected):void{
7786
$this::assertSame(Str::containsAny('Hello world!', $needles, $ignoreCase), $expected);
7887
}
7988

80-
8189
}

0 commit comments

Comments
 (0)