Skip to content

Commit fb1da45

Browse files
author
Dmitry Tarasov
committed
Add API key validation
1 parent b4e35ad commit fb1da45

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Stackify/Log/Transport/AbstractApiTransport.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract class AbstractApiTransport extends AbstractTransport
2020
public function __construct($apiKey, array $options = array())
2121
{
2222
parent::__construct();
23-
$this->apiKey = $apiKey;
23+
$this->apiKey = $this->validateApiKey($apiKey);
2424
$this->extractOptions($options);
2525
register_shutdown_function(array($this, 'finish'));
2626
}
@@ -68,4 +68,13 @@ protected function getApiHeaders()
6868
);
6969
}
7070

71+
private function validateApiKey($value)
72+
{
73+
$apiKey = trim($value);
74+
if (empty($apiKey)) {
75+
throw new InitializationException('API key cannot be empty');
76+
}
77+
return $apiKey;
78+
}
79+
7180
}

0 commit comments

Comments
 (0)