Skip to content

Commit

Permalink
Check for values that could be null
Browse files Browse the repository at this point in the history
  • Loading branch information
ammardev committed Oct 16, 2022
1 parent a6c01c8 commit d3dfe8c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Apn.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ public function decorateHeaders(array $headers): array
public function prepareHandle($deviceToken, array $message)
{
$uri = false === $this->config['dry_run'] ? $this->getProductionUrl($deviceToken) : $this->getSandboxUrl($deviceToken);
$headers = $message['headers'];
unset($message['headers']);
$headers = $message['headers'] ?? [];
if (isset($message['headers'])) {
unset($message['headers']);
}
$body = json_encode($message);

$config = $this->config;
Expand All @@ -269,10 +271,13 @@ public function prepareHandle($deviceToken, array $message)
CURLOPT_HEADER => true,

CURLOPT_SSLCERT => $config['certificate'],
CURLOPT_SSLCERTPASSWD => $config['passPhrase'],
CURLOPT_SSL_VERIFYPEER => true
];

if (isset($config['passPhrase'])) {
$options[CURLOPT_SSLCERTPASSWD] = $config['passPhrase'];
}

$ch = curl_init();

curl_setopt_array($ch, $options);
Expand Down

0 comments on commit d3dfe8c

Please sign in to comment.