Skip to content

Instantly share code, notes, and snippets.

@szyku-tsh
szyku-tsh / naive2.php
Created June 10, 2019 09:36 — forked from szyku/naive2.php
naivefopen2
<?php
class XYZ {
// ...
public static function openForRead(string $id): ?resouce
{
$resource = @fopen($id, 'r');
return $resource ? $resource : null;
}
}
@szyku-tsh
szyku-tsh / naive1.php
Created June 10, 2019 09:34 — forked from szyku/naive1.php
naive1
<?php
class XYZ {
// ...
public function openForRead($id)
{
return @fopen($id, 'r');
}
}
@szyku-tsh
szyku-tsh / namespaced.php
Created April 28, 2019 09:00
Namespaced exception
<?php
namespace App\DocSigning\Exception;
use BaseSigningException;
final class SigningServiceUnavailable extends BaseSigningException {/* ... */}
@szyku-tsh
szyku-tsh / exception1.php
Created April 27, 2019 18:05
First attempt
<?php
//....
$action = DocumentSigningAction::create($doc);
/** @var \Psr\Http\Message\ResponseInterface $response */
$response = $action->execute();
if ($response->getStatusCode() !== 200) {
throw new SigningException("Could not sign document");
}