Skip to content

Commit

Permalink
Code style, doc-blocks and clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSlabon committed Dec 18, 2018
1 parent e0e637a commit 4f9566c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ composer.phar
/vendor/
/private/
/tests/functional/*.pdf

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
Binary file removed signed-and-timestamped.pdf
Binary file not shown.
Binary file removed signed.pdf
Binary file not shown.
7 changes: 5 additions & 2 deletions src/SignatureModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
/**
* @return string
*/
public function getCertificate()
public function getCertificate(): string
{
return $this->identity->getSigningCertificate();
}
Expand All @@ -77,7 +77,7 @@ public function createSignature(\SetaPDF_Core_Reader_FilePath $tmpPath): string
$this->module->setExtraCertificates([$this->client->getCertificatePath()]);

// For backwards compatibility
if (method_exists($this->module, 'setOcspResponse')) {
if (\method_exists($this->module, 'setOcspResponse')) {
$this->module->setOcspResponse($this->identity->getOcspResponse());
} else {
$this->addOcspResponse();
Expand All @@ -93,9 +93,12 @@ public function createSignature(\SetaPDF_Core_Reader_FilePath $tmpPath): string

/**
* Adds the OCSP response as a signed attribute in the CMS container.
*
* @throws \SetaPDF_Signer_Exception
*/
protected function addOcspResponse(): void
{
/** @var \SetaPDF_Signer_Asn1_Element $cms */
$cms = $this->module->getCms();
$signerInfos = \SetaPDF_Signer_Asn1_Element::findByPath('1/0/4', $cms);
if (($signerInfos->getIdent() & "\xA1") === "\xA1") {
Expand Down
5 changes: 4 additions & 1 deletion src/TimestampModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class TimestampModule implements
*/
protected $identity;

/**
* @param Client $client
*/
public function __construct(Client $client)
{
$this->client = $client;
Expand All @@ -50,7 +53,7 @@ public function createTimestamp($data)
* @param string|\SetaPDF_Core_Reader_FilePath $data The hash of the main signature
* @return string
*/
protected function getHash($data)
protected function getHash($data): string
{
if ($data instanceof \SetaPDF_Core_Reader_FilePath) {
return \hash_file('sha256', $data->getPath());
Expand Down

0 comments on commit 4f9566c

Please sign in to comment.