Skip to content

Commit 3e9d402

Browse files
committed
Merge branch 'doc-blocks'
2 parents 452d31b + 33a32cb commit 3e9d402

27 files changed

+378
-7
lines changed

lib/Providers/Qr/BaseHTTPQRCodeProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44

55
abstract class BaseHTTPQRCodeProvider implements IQRCodeProvider
66
{
7+
/** @var bool */
78
protected $verifyssl;
89

10+
/**
11+
* @param string $url
12+
*
13+
* @return string|bool
14+
*/
915
protected function getContent($url)
1016
{
1117
$curlhandle = curl_init();

lib/Providers/Qr/IQRCodeProvider.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44

55
interface IQRCodeProvider
66
{
7+
/**
8+
* Generate and return the QR code to embed in a web page
9+
*
10+
* @param string $qrtext the value to encode in the QR code
11+
* @param int $size the desired size of the QR code
12+
*
13+
* @return string file contents of the QR code
14+
*/
715
public function getQRCodeImage($qrtext, $size);
16+
17+
/**
18+
* Returns the appropriate mime type for the QR code
19+
* that will be generated
20+
*
21+
* @return string
22+
*/
823
public function getMimeType();
924
}

lib/Providers/Qr/ImageChartsQRCodeProvider.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@
55
// https://image-charts.com
66
class ImageChartsQRCodeProvider extends BaseHTTPQRCodeProvider
77
{
8+
/** @var string */
89
public $errorcorrectionlevel;
10+
11+
/** @var int */
912
public $margin;
1013

14+
/**
15+
* @param bool $verifyssl
16+
* @param string $errorcorrectionlevel
17+
* @param int $margin
18+
*/
1119
public function __construct($verifyssl = false, $errorcorrectionlevel = 'L', $margin = 1)
1220
{
1321
if (!is_bool($verifyssl)) {
@@ -20,16 +28,28 @@ public function __construct($verifyssl = false, $errorcorrectionlevel = 'L', $ma
2028
$this->margin = $margin;
2129
}
2230

31+
/**
32+
* {@inheritdoc}
33+
*/
2334
public function getMimeType()
2435
{
2536
return 'image/png';
2637
}
2738

39+
/**
40+
* {@inheritdoc}
41+
*/
2842
public function getQRCodeImage($qrtext, $size)
2943
{
3044
return $this->getContent($this->getUrl($qrtext, $size));
3145
}
3246

47+
/**
48+
* @param string $qrtext the value to encode in the QR code
49+
* @param int $size the desired size of the QR code
50+
*
51+
* @return string file contents of the QR code
52+
*/
3353
public function getUrl($qrtext, $size)
3454
{
3555
return 'https://image-charts.com/chart?cht=qr'

lib/Providers/Qr/QRServerProvider.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,33 @@
55
// http://goqr.me/api/doc/create-qr-code/
66
class QRServerProvider extends BaseHTTPQRCodeProvider
77
{
8+
/** @var string */
89
public $errorcorrectionlevel;
10+
11+
/** @var int */
912
public $margin;
13+
14+
/** @var int */
1015
public $qzone;
16+
17+
/** @var string */
1118
public $bgcolor;
19+
20+
/** @var string */
1221
public $color;
22+
23+
/** @var string */
1324
public $format;
1425

26+
/**
27+
* @param bool $verifyssl
28+
* @param string $errorcorrectionlevel
29+
* @param int $margin
30+
* @param int $qzone
31+
* @param string $bgcolor
32+
* @param string $color
33+
* @param string $format
34+
*/
1535
public function __construct($verifyssl = false, $errorcorrectionlevel = 'L', $margin = 4, $qzone = 1, $bgcolor = 'ffffff', $color = '000000', $format = 'png')
1636
{
1737
if (!is_bool($verifyssl)) {
@@ -28,6 +48,9 @@ public function __construct($verifyssl = false, $errorcorrectionlevel = 'L', $ma
2848
$this->format = $format;
2949
}
3050

51+
/**
52+
* {@inheritdoc}
53+
*/
3154
public function getMimeType()
3255
{
3356
switch (strtolower($this->format)) {
@@ -46,16 +69,30 @@ public function getMimeType()
4669
throw new QRException(sprintf('Unknown MIME-type: %s', $this->format));
4770
}
4871

72+
/**
73+
* {@inheritdoc}
74+
*/
4975
public function getQRCodeImage($qrtext, $size)
5076
{
5177
return $this->getContent($this->getUrl($qrtext, $size));
5278
}
5379

80+
/**
81+
* @param string $value
82+
*
83+
* @return string
84+
*/
5485
private function decodeColor($value)
5586
{
5687
return vsprintf('%d-%d-%d', sscanf($value, "%02x%02x%02x"));
5788
}
5889

90+
/**
91+
* @param string $qrtext the value to encode in the QR code
92+
* @param int|string $size the desired size of the QR code
93+
*
94+
* @return string file contents of the QR code
95+
*/
5996
public function getUrl($qrtext, $size)
6097
{
6198
return 'https://api.qrserver.com/v1/create-qr-code/'

lib/Providers/Qr/QRicketProvider.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@
55
// http://qrickit.com/qrickit_apps/qrickit_api.php
66
class QRicketProvider extends BaseHTTPQRCodeProvider
77
{
8+
/** @var string */
89
public $errorcorrectionlevel;
9-
public $margin;
10-
public $qzone;
10+
11+
/** @var string */
1112
public $bgcolor;
13+
14+
/** @var string */
1215
public $color;
16+
17+
/** @var string */
1318
public $format;
1419

20+
/**
21+
* @param string $errorcorrectionlevel
22+
* @param string $bgcolor
23+
* @param string $color
24+
* @param string $format
25+
*/
1526
public function __construct($errorcorrectionlevel = 'L', $bgcolor = 'ffffff', $color = '000000', $format = 'p')
1627
{
1728
$this->verifyssl = false;
@@ -22,6 +33,9 @@ public function __construct($errorcorrectionlevel = 'L', $bgcolor = 'ffffff', $c
2233
$this->format = $format;
2334
}
2435

36+
/**
37+
* {@inheritdoc}
38+
*/
2539
public function getMimeType()
2640
{
2741
switch (strtolower($this->format)) {
@@ -35,11 +49,20 @@ public function getMimeType()
3549
throw new QRException(sprintf('Unknown MIME-type: %s', $this->format));
3650
}
3751

52+
/**
53+
* {@inheritdoc}
54+
*/
3855
public function getQRCodeImage($qrtext, $size)
3956
{
4057
return $this->getContent($this->getUrl($qrtext, $size));
4158
}
4259

60+
/**
61+
* @param string $qrtext the value to encode in the QR code
62+
* @param int|string $size the desired size of the QR code
63+
*
64+
* @return string file contents of the QR code
65+
*/
4366
public function getUrl($qrtext, $size)
4467
{
4568
return 'http://qrickit.com/api/qr'

lib/Providers/Rng/CSRNGProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44

55
class CSRNGProvider implements IRNGProvider
66
{
7+
/**
8+
* {@inheritdoc}
9+
*/
710
public function getRandomBytes($bytecount)
811
{
912
return random_bytes($bytecount); // PHP7+
1013
}
1114

15+
/**
16+
* {@inheritdoc}
17+
*/
1218
public function isCryptographicallySecure()
1319
{
1420
return true;

lib/Providers/Rng/HashRNGProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
class HashRNGProvider implements IRNGProvider
66
{
7+
/** @var string */
78
private $algorithm;
89

10+
/**
11+
* @param string $algorithm
12+
*/
913
public function __construct($algorithm = 'sha256')
1014
{
1115
$algos = array_values(hash_algos());
@@ -15,6 +19,9 @@ public function __construct($algorithm = 'sha256')
1519
$this->algorithm = $algorithm;
1620
}
1721

22+
/**
23+
* {@inheritdoc}
24+
*/
1825
public function getRandomBytes($bytecount)
1926
{
2027
$result = '';
@@ -26,6 +33,9 @@ public function getRandomBytes($bytecount)
2633
return $result;
2734
}
2835

36+
/**
37+
* {@inheritdoc}
38+
*/
2939
public function isCryptographicallySecure()
3040
{
3141
return false;

lib/Providers/Rng/IRNGProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
interface IRNGProvider
66
{
7+
/**
8+
* @param int $bytecount the number of bytes of randomness to return
9+
*
10+
* @return string the random bytes
11+
*/
712
public function getRandomBytes($bytecount);
13+
14+
/**
15+
* @return bool whether this provider is cryptographically secure
16+
*/
817
public function isCryptographicallySecure();
918
}

lib/Providers/Rng/MCryptRNGProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
class MCryptRNGProvider implements IRNGProvider
66
{
7+
/** @var int */
78
private $source;
89

10+
/**
11+
* @param int $source
12+
*/
913
public function __construct($source = MCRYPT_DEV_URANDOM)
1014
{
1115
$this->source = $source;
1216
}
1317

18+
/**
19+
* {@inheritdoc}
20+
*/
1421
public function getRandomBytes($bytecount)
1522
{
1623
$result = @mcrypt_create_iv($bytecount, $this->source);
@@ -20,6 +27,9 @@ public function getRandomBytes($bytecount)
2027
return $result;
2128
}
2229

30+
/**
31+
* {@inheritdoc}
32+
*/
2333
public function isCryptographicallySecure()
2434
{
2535
return true;

lib/Providers/Rng/OpenSSLRNGProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
class OpenSSLRNGProvider implements IRNGProvider
66
{
7+
/** @var bool */
78
private $requirestrong;
89

10+
/**
11+
* @param bool $requirestrong
12+
*/
913
public function __construct($requirestrong = true)
1014
{
1115
$this->requirestrong = $requirestrong;
1216
}
1317

18+
/**
19+
* {@inheritdoc}
20+
*/
1421
public function getRandomBytes($bytecount)
1522
{
1623
$result = openssl_random_pseudo_bytes($bytecount, $crypto_strong);
@@ -23,6 +30,9 @@ public function getRandomBytes($bytecount)
2330
return $result;
2431
}
2532

33+
/**
34+
* {@inheritdoc}
35+
*/
2636
public function isCryptographicallySecure()
2737
{
2838
return $this->requirestrong;

lib/Providers/Time/HttpTimeProvider.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,26 @@
99
*/
1010
class HttpTimeProvider implements ITimeProvider
1111
{
12+
/** @var string */
1213
public $url;
13-
public $options;
14+
15+
/** @var string */
1416
public $expectedtimeformat;
1517

18+
/** @var array */
19+
public $options;
20+
21+
/**
22+
* @param string $url
23+
* @param string $expectedtimeformat
24+
* @param array $options
25+
*/
1626
public function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
1727
{
1828
$this->url = $url;
1929
$this->expectedtimeformat = $expectedtimeformat;
20-
$this->options = $options;
21-
if ($this->options === null) {
22-
$this->options = array(
30+
if ($options === null) {
31+
$options = array(
2332
'http' => array(
2433
'method' => 'HEAD',
2534
'follow_location' => false,
@@ -34,8 +43,12 @@ public function __construct($url = 'https://google.com', $expectedtimeformat = '
3443
)
3544
);
3645
}
46+
$this->options = $options;
3747
}
3848

49+
/**
50+
* {@inheritdoc}
51+
*/
3952
public function getTime()
4053
{
4154
try {

lib/Providers/Time/ITimeProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44

55
interface ITimeProvider
66
{
7+
/**
8+
* @return int the current timestamp according to this provider
9+
*/
710
public function getTime();
811
}

0 commit comments

Comments
 (0)