| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | public static function certificateFromLocalPath(string $path): SslCertificate |
||
| 38 | { |
||
| 39 | if (! file_exists($path)) { |
||
| 40 | throw CouldNotLoadLocalCertificate::certificatePathNotFound($path); |
||
| 41 | } |
||
| 42 | |||
| 43 | if (! is_readable($path)) { |
||
| 44 | throw CouldNotLoadLocalCertificate::certificateFilePermissionInvalid($path); |
||
| 45 | } |
||
| 46 | |||
| 47 | $certificateString = file_get_contents($path); |
||
| 48 | if (! $certificateString) { |
||
| 49 | throw CouldNotLoadLocalCertificate::certificateFileReadFailed($path); |
||
| 50 | } |
||
| 51 | |||
| 52 | return (new static())->parseCertificate($certificateString); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.