Skip to content

Commit

Permalink
use realpath to check files
Browse files Browse the repository at this point in the history
  • Loading branch information
miladrahimi committed Jun 1, 2024
1 parent 353477e commit 95ccc64
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Cryptography/Keys/EcdsaPrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class EcdsaPrivateKey
{
/**
* @var resource Key resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -24,7 +24,7 @@ class EcdsaPrivateKey
*/
public function __construct(string $key, string $passphrase = '', ?string $id = null)
{
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand All @@ -35,7 +35,7 @@ public function __construct(string $key, string $passphrase = '', ?string $id =
}

/**
* @return resource
* @return mixed
*/
public function getResource()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Cryptography/Keys/EcdsaPublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class EcdsaPublicKey
{
/**
* @var resource Key resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -23,7 +23,7 @@ class EcdsaPublicKey
*/
public function __construct(string $key, ?string $id = null)
{
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand All @@ -34,7 +34,7 @@ public function __construct(string $key, ?string $id = null)
}

/**
* @return resource
* @return mixed
*/
public function getResource()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Cryptography/Keys/RsaPrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class RsaPrivateKey
{
/**
* @var resource Key resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -24,7 +24,7 @@ class RsaPrivateKey
*/
public function __construct(string $key, string $passphrase = '', ?string $id = null)
{
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand All @@ -35,7 +35,7 @@ public function __construct(string $key, string $passphrase = '', ?string $id =
}

/**
* @return resource
* @return mixed
*/
public function getResource()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Cryptography/Keys/RsaPublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class RsaPublicKey
{
/**
* @var resource Key resource handler
* @var mixed Key resource handler
*/
protected $resource;

Expand All @@ -23,7 +23,7 @@ class RsaPublicKey
*/
public function __construct(string $key, ?string $id = null)
{
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;
$content = realpath($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand All @@ -34,7 +34,7 @@ public function __construct(string $key, ?string $id = null)
}

/**
* @return resource
* @return mixed
*/
public function getResource()
{
Expand Down

0 comments on commit 95ccc64

Please sign in to comment.