Completed
Branch master (fe036c)
by
unknown
02:31
created
examples/op_return_payment_api_example.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use BitWasp\BitcoinLib\RawTransaction;
4 3
 use Blocktrail\SDK\Blocktrail;
5 4
 use Blocktrail\SDK\BlocktrailSDK;
6 5
 use Blocktrail\SDK\Connection\Exceptions\ObjectNotFound;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use Blocktrail\SDK\BlocktrailSDK;
4 4
 
5
-require_once __DIR__ . "/../vendor/autoload.php";
5
+require_once __DIR__."/../vendor/autoload.php";
6 6
 
7 7
 /*
8 8
     This simple example shows how to get the payload when your webhook is called.
Please login to merge, or discard this patch.
src/BackupGenerator.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@
 block discarded – undo
262 262
      * generate image file of backup details, ready to
263 263
      *
264 264
      * @param null $filename        filename to save image as (optional - if ommited raw image stream is outputted instead)
265
-     * @return bool
265
+     * @return null|boolean
266 266
      */
267 267
     public function generateImg($filename = null) {
268 268
         //create blocktrail pub key QR codes if not already done
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,6 @@
 block discarded – undo
55 55
 
56 56
     /**
57 57
      * BIP32 master backup public key (M/)
58
-
59 58
      * @var BIP32Key
60 59
      */
61 60
     protected $backupPublicKey;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
             define('DOMPDF_ENABLE_AUTOLOAD', false);
65 65
 
66 66
             //try the different possible locations for the config file, depending on if the sdk is included as a dependency or is the main project itself
67
-            (@include_once __DIR__ . '/../../../dompdf/dompdf/dompdf_config.inc.php') || @include_once __DIR__ . '/../vendor/dompdf/dompdf/dompdf_config.inc.php';
67
+            (@include_once __DIR__.'/../../../dompdf/dompdf/dompdf_config.inc.php') || @include_once __DIR__.'/../vendor/dompdf/dompdf/dompdf_config.inc.php';
68 68
         }
69 69
 
70 70
         //set the fonts path
71
-        $this->fontsPath = dirname(__FILE__) . '/../resources/fonts';
71
+        $this->fontsPath = dirname(__FILE__).'/../resources/fonts';
72 72
 
73 73
         $this->primaryMnemonic = $primaryMnemonic;
74 74
         $this->backupMnemonic = $backupMnemonic;
75 75
 
76
-        $this->blocktrailPublicKeys = array_map(function ($key) {
76
+        $this->blocktrailPublicKeys = array_map(function($key) {
77 77
             return BIP32Key::create($key); // M/9999' or M/0' or M/1'
78 78
         }, $blocktrailPublicKeys);
79 79
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             $qrCode = new QrCode();
88 88
             $qrCode
89 89
                 ->setText($key->key())
90
-                ->setSize(self::QR_CODE_SIZE-20)
90
+                ->setSize(self::QR_CODE_SIZE - 20)
91 91
                 ->setPadding(10)
92 92
                 ->setErrorCorrection('high')
93 93
                 ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         }
272 272
         //create the image canvas - use the count of blocktrail pub keys to augment appropriately
273 273
         $totalPubKeys = count($this->blocktrailPubKeyQRs);
274
-        $increaseCanvas = ceil($totalPubKeys/4) * (self::QR_CODE_SIZE + 30);
274
+        $increaseCanvas = ceil($totalPubKeys / 4) * (self::QR_CODE_SIZE + 30);
275 275
         $image = imagecreatetruecolor(1024, 600 + $increaseCanvas);
276 276
 
277 277
         //create colours
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         $xPos = $leftMargin;
335 335
         $i = 0;
336 336
         foreach ($this->blocktrailPubKeyQRs as $btPubKey) {
337
-            imagecopy($image, $btPubKey['qrImg'], $xPos, $yPos, 0, 0, self::QR_CODE_SIZE, self::QR_CODE_SIZE+20);
337
+            imagecopy($image, $btPubKey['qrImg'], $xPos, $yPos, 0, 0, self::QR_CODE_SIZE, self::QR_CODE_SIZE + 20);
338 338
 
339 339
             //increment to help decide when to start a new row
340 340
             $i++;
Please login to merge, or discard this patch.
src/Bitcoin/BIP32Key.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     /**
76 76
      * get tuple of the key and path, the way BitcoinLib likes it
77 77
      *
78
-     * @return array        [key, path]
78
+     * @return string[]        [key, path]
79 79
      */
80 80
     public function tuple() {
81 81
         return [$this->key, (string)$this->path];
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     /**
92 92
      * build child key
93 93
      *
94
-     * @param string|BIP32Path  $path
94
+     * @param BIP32Path  $path
95 95
      * @return BIP32Key
96 96
      * @throws \Exception
97 97
      */
Please login to merge, or discard this patch.
src/BlocktrailSDK.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * normalize network string
60 60
      *
61 61
      * @param $network
62
-     * @param $testnet
62
+     * @param boolean $testnet
63 63
      * @return array
64 64
      * @throws \Exception
65 65
      */
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
      * convert a Satoshi value to a BTC value
1090 1090
      *
1091 1091
      * @param int       $satoshi
1092
-     * @return float
1092
+     * @return string
1093 1093
      */
1094 1094
     public static function toBTC($satoshi) {
1095 1095
         return bcdiv((int)(string)$satoshi, 100000000, 8);
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
      * convert a BTC value to a Satoshi value
1120 1120
      *
1121 1121
      * @param float     $btc
1122
-     * @return string
1122
+     * @return integer
1123 1123
      */
1124 1124
     public static function toSatoshi($btc) {
1125 1125
         return (int)self::toSatoshiString($btc);
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
     /**
1129 1129
      * json_decode helper that throws exceptions when it fails to decode
1130 1130
      *
1131
-     * @param      $json
1131
+     * @param      string $json
1132 1132
      * @param bool $assoc
1133 1133
      * @return mixed
1134 1134
      * @throws \Exception
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,6 @@
 block discarded – undo
55 55
 
56 56
     /**
57 57
      * BIP32 master backup public key (M/)
58
-
59 58
      * @var BIP32Key
60 59
      */
61 60
     protected $backupPublicKey;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @param $testnet
93 93
      */
94 94
     protected function setBitcoinLibMagicBytes($network, $testnet) {
95
-        BitcoinLib::setMagicByteDefaults($network . ($testnet ? '-testnet' : ''));
95
+        BitcoinLib::setMagicByteDefaults($network.($testnet ? '-testnet' : ''));
96 96
     }
97 97
 
98 98
     /**
@@ -648,10 +648,7 @@  discard block
 block discarded – undo
648 648
         }
649 649
 
650 650
         $identifier = $options['identifier'];
651
-        $readonly = isset($options['readonly']) ? $options['readonly'] :
652
-                    (isset($options['readOnly']) ? $options['readOnly'] :
653
-                        (isset($options['read-only']) ? $options['read-only'] :
654
-                            false));
651
+        $readonly = isset($options['readonly']) ? $options['readonly'] : (isset($options['readOnly']) ? $options['readOnly'] : (isset($options['read-only']) ? $options['read-only'] : false));
655 652
 
656 653
         // get the wallet data from the server
657 654
         $data = $this->getWallet($identifier);
Please login to merge, or discard this patch.
src/BlocktrailSDKInterface.php 2 patches
Doc Comments   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,6 +9,11 @@  discard block
 block discarded – undo
9 9
  */
10 10
 interface BlocktrailSDKInterface {
11 11
 
12
+    /**
13
+     * @param string $apiSecret
14
+     *
15
+     * @return void
16
+     */
12 17
     public function __construct($apiKey, $apiSecret, $network = 'BTC', $testnet = false, $apiVersion = 'v1', $apiEndpoint = null);
13 18
 
14 19
     /**
@@ -17,6 +22,7 @@  discard block
 block discarded – undo
17 22
      * @param   bool        $debug
18 23
      *
19 24
      * @codeCoverageIgnore
25
+     * @return void
20 26
      */
21 27
     public function setCurlDebugging($debug = true);
22 28
 
@@ -26,6 +32,7 @@  discard block
 block discarded – undo
26 32
      * @param   bool        $verboseErrors
27 33
      *
28 34
      * @codeCoverageIgnore
35
+     * @return void
29 36
      */
30 37
     public function setVerboseErrors($verboseErrors = true);
31 38
     
@@ -35,6 +42,7 @@  discard block
 block discarded – undo
35 42
      * @param bool      $value
36 43
      *
37 44
      * @codeCoverageIgnore
45
+     * @return void
38 46
      */
39 47
     public function setCurlDefaultOption($key, $value);
40 48
 
@@ -371,7 +379,7 @@  discard block
 block discarded – undo
371 379
      *
372 380
      * @param string    $identifier             the identifier of the wallet
373 381
      * @param string    $rawTransaction         raw hex of the transaction (should be partially signed)
374
-     * @param array     $paths                  list of the paths that were used for the UTXO
382
+     * @param string[]     $paths                  list of the paths that were used for the UTXO
375 383
      * @param bool      $checkFee               let the server verify the fee after signing
376 384
      * @return string                           the complete raw transaction
377 385
      * @throws \Exception
@@ -443,22 +451,22 @@  discard block
 block discarded – undo
443 451
     /**
444 452
      * lock a specific unspent output
445 453
      *
446
-     * @param     $identifier
454
+     * @param     string $identifier
447 455
      * @param     $txHash
448 456
      * @param     $txIdx
449 457
      * @param int $ttl
450 458
      * @return
451
-     */
459
+     boolean
452 460
     public function lockWalletUTXO($identifier, $txHash, $txIdx, $ttl = 3);
453 461
 
454 462
     /**
455 463
      * unlock a specific unspent output
456 464
      *
457
-     * @param     $identifier
465
+     * @param     string $identifier
458 466
      * @param     $txHash
459 467
      * @param     $txIdx
460 468
      * @return
461
-     */
469
+     boolean
462 470
     public function unlockWalletUTXO($identifier, $txHash, $txIdx);
463 471
 
464 472
     /**
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,6 @@
 block discarded – undo
55 55
 
56 56
     /**
57 57
      * BIP32 master backup public key (M/)
58
-
59 58
      * @var BIP32Key
60 59
      */
61 60
     protected $backupPublicKey;
Please login to merge, or discard this patch.
src/Connection/RestClient.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -44,6 +44,11 @@
 block discarded – undo
44 44
      */
45 45
     protected $verboseErrors = false;
46 46
 
47
+    /**
48
+     * @param string $apiVersion
49
+     * @param string $apiKey
50
+     * @param string $apiSecret
51
+     */
47 52
     public function __construct($apiEndpoint, $apiVersion, $apiKey, $apiSecret) {
48 53
         $this->guzzle = new Guzzle(array(
49 54
             'base_url' => $apiEndpoint,
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use GuzzleHttp\Client as Guzzle;
6 6
 use GuzzleHttp\Message\RequestInterface;
7 7
 use GuzzleHttp\Message\ResponseInterface;
8
-use GuzzleHttp\Post\PostBodyInterface;
9 8
 use GuzzleHttp\Query;
10 9
 use GuzzleHttp\Stream\Stream;
11 10
 use HttpSignatures\Context;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             'base_url' => $apiEndpoint,
50 50
             'defaults' => array(
51 51
                 'headers' => array(
52
-                    'User-Agent' => Blocktrail::SDK_USER_AGENT . '/' . Blocktrail::SDK_VERSION
52
+                    'User-Agent' => Blocktrail::SDK_USER_AGENT.'/'.Blocktrail::SDK_VERSION
53 53
                 ),
54 54
                 'exceptions' => false,
55 55
                 'connect_timeout' => 3,
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             $request->setHeader('Content-MD5', md5((string)$body));
214 214
         } else {
215 215
             $qs = (string)$request->getQuery();
216
-            $request->setHeader('Content-MD5', md5($request->getPath() . ($qs ? "?{$qs}" : "")));
216
+            $request->setHeader('Content-MD5', md5($request->getPath().($qs ? "?{$qs}" : "")));
217 217
         }
218 218
 
219 219
         if ($auth !== null) {
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
                 throw new ObjectNotFound($this->verboseErrors ? $body : Blocktrail::EXCEPTION_OBJECT_NOT_FOUND, $httpResponseCode);
277 277
             }
278 278
         } elseif ($httpResponseCode == 500) {
279
-            throw new GenericServerError(Blocktrail::EXCEPTION_GENERIC_SERVER_ERROR . "\nServer Response: " . $body, $httpResponseCode);
279
+            throw new GenericServerError(Blocktrail::EXCEPTION_GENERIC_SERVER_ERROR."\nServer Response: ".$body, $httpResponseCode);
280 280
         } else {
281
-            throw new GenericHTTPError(Blocktrail::EXCEPTION_GENERIC_HTTP_ERROR . "\nServer Response: " . $body, $httpResponseCode);
281
+            throw new GenericHTTPError(Blocktrail::EXCEPTION_GENERIC_HTTP_ERROR."\nServer Response: ".$body, $httpResponseCode);
282 282
         }
283 283
     }
284 284
 
Please login to merge, or discard this patch.
src/WalletInterface.php 1 patch
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,6 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param string                        $network
25 25
      * @param bool                          $testnet
26 26
      * @param string                        $checksum
27
+     * @return void
27 28
      */
28 29
     public function __construct(BlocktrailSDKInterface $sdk, $identifier, $primaryMnemonic, $primaryPublicKey, $backupPublicKey, $blocktrailPublicKeys, $keyIndex, $network, $testnet, $checksum);
29 30
 
@@ -92,7 +93,7 @@  discard block
 block discarded – undo
92 93
      * get address and redeemScript for specified path
93 94
      *
94 95
      * @param string    $path
95
-     * @return array[string, string]     [address, redeemScript]
96
+     * @return string[] string]     [address, redeemScript]
96 97
      */
97 98
     public function getRedeemScriptByPath($path);
98 99
 
Please login to merge, or discard this patch.
src/WalletSweeper.php 2 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * normalize network string
122 122
      *
123
-     * @param $network
124
-     * @param $testnet
123
+     * @param string $network
124
+     * @param boolean $testnet
125 125
      * @return array
126 126
      * @throws \Exception
127 127
      */
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
     /**
152 152
      * generate multisig address for given path
153 153
      *
154
-     * @param $path
155
-     * @return array
154
+     * @param string $path
155
+     * @return string[]
156 156
      * @throws \Exception
157 157
      */
158 158
     protected function createAddress($path) {
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
     /**
176 176
      * create a batch of multisig addresses
177 177
      *
178
-     * @param $start
179
-     * @param $count
178
+     * @param integer $start
179
+     * @param integer $count
180 180
      * @param $keyIndex
181 181
      * @return array
182 182
      */
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     /**
206 206
      * gets the blocktrail pub key for the given path from the stored array of pub keys
207 207
      *
208
-     * @param string|BIP32Path  $path
208
+     * @param BIP32Path  $path
209 209
      * @return BIP32Key
210 210
      * @throws \Exception
211 211
      */
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     /**
316 316
      * create a signed transaction sending all the found outputs to the given address
317 317
      *
318
-     * @param $destinationAddress
318
+     * @param string $destinationAddress
319 319
      * @return array
320 320
      * @throws \Exception
321 321
      */
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     /**
370 370
      * signs a raw transaction
371 371
      *
372
-     * @param $rawTransaction
372
+     * @param string $rawTransaction
373 373
      * @param $inputs
374 374
      * @return array
375 375
      */
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function __construct($primaryMnemonic, $primaryPassphrase, $backupMnemonic, array $blocktrailPublicKeys, BlockchainDataServiceInterface $bitcoinClient, $network = 'btc', $testnet = false) {
79 79
         // normalize network and set bitcoinlib to the right magic-bytes
80 80
         list($this->network, $this->testnet) = $this->normalizeNetwork($network, $testnet);
81
-        BitcoinLib::setMagicByteDefaults($this->network . ($this->testnet ? '-testnet' : ''));
81
+        BitcoinLib::setMagicByteDefaults($this->network.($this->testnet ? '-testnet' : ''));
82 82
 
83 83
         //create BIP32 keys for the Blocktrail public keys
84 84
         foreach ($blocktrailPublicKeys as $blocktrailKey) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
         for ($i = 0; $i < $count; $i++) {
187 187
             //create a path subsequent address
188
-            $path = (string)WalletPath::create($keyIndex, $_chain = 0, $start+$i)->path()->publicPath();
188
+            $path = (string)WalletPath::create($keyIndex, $_chain = 0, $start + $i)->path()->publicPath();
189 189
             list($address, $redeem) = $this->createAddress($path);
190 190
             $addresses[$address] = array(
191 191
                 //'address' => $address,
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         $totalUTXOs = 0;
233 233
         $totalAddressesGenerated = 0;
234 234
 
235
-        $addressUTXOs = array();    //addresses and their utxos, paths and redeem scripts
235
+        $addressUTXOs = array(); //addresses and their utxos, paths and redeem scripts
236 236
 
237 237
         //for each blocktrail pub key, do fund discovery on batches of addresses
238 238
         foreach ($this->blocktrailPublicKeys as $keyIndex => $blocktrailPubKey) {
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                     $totalUTXOs += count($outputs);
261 261
 
262 262
                     //add up the total utxo value for all addresses
263
-                    $totalBalance = array_reduce($outputs, function ($carry, $output) {
263
+                    $totalBalance = array_reduce($outputs, function($carry, $output) {
264 264
                         return $carry += $output['value'];
265 265
                     }, $totalBalance);
266 266
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         foreach ($this->sweepData['utxos'] as $address => $data) {
330 330
             $inputs = array_merge(
331 331
                 $inputs,
332
-                array_map(function ($utxo) use ($address, $data) {
332
+                array_map(function($utxo) use ($address, $data) {
333 333
                     return [
334 334
                         'txid' => $utxo['hash'],
335 335
                         'vout' => $utxo['index'],
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         }
388 388
 
389 389
         //add the keys and redeem scripts to a wallet to sign the transaction with
390
-        BIP32::bip32_keys_to_wallet($wallet, array_map(function (BIP32Key $key) {
390
+        BIP32::bip32_keys_to_wallet($wallet, array_map(function(BIP32Key $key) {
391 391
             return $key->tuple();
392 392
         }, $keys));
393 393
         RawTransaction::redeem_scripts_to_wallet($wallet, $redeemScripts);
Please login to merge, or discard this patch.
coverage-checker.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 }
11 11
 
12 12
 $inputFile  = $argv[1];
13
-$percentage = min(100, max(0, (int) $argv[2]));
13
+$percentage = min(100, max(0, (int)$argv[2]));
14 14
 
15 15
 if (!file_exists($inputFile)) {
16 16
     throw new InvalidArgumentException('Invalid input file provided');
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 $checkedElements = 0;
27 27
 
28 28
 $excludes = [
29
-    "/^Blocktrail\\\\SDK\\\\Console/",  // just wrappers and a pain in the ass to test
30
-    "/Compiler\\.php/",                 // just a tool and copy paste from Composer
31
-    "/BackupGenerator\\.php/",          // tmp excluding, it's rather hard to test the whole process
32
-    "/WalletSweeper\\.php/",            // because we're running it's test without coverage (because xdebug is REALLY slow)
29
+    "/^Blocktrail\\\\SDK\\\\Console/", // just wrappers and a pain in the ass to test
30
+    "/Compiler\\.php/", // just a tool and copy paste from Composer
31
+    "/BackupGenerator\\.php/", // tmp excluding, it's rather hard to test the whole process
32
+    "/WalletSweeper\\.php/", // because we're running it's test without coverage (because xdebug is REALLY slow)
33 33
 ];
34 34
 
35 35
 foreach ($xml->xpath("//package") as $package) {
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 }
83 83
 
84 84
 foreach ($xml->xpath("//project/file/metrics") as $metric) {
85
-    $totalElements   += (int) $metric['elements'];
86
-    $checkedElements += (int) $metric['coveredelements'];
85
+    $totalElements   += (int)$metric['elements'];
86
+    $checkedElements += (int)$metric['coveredelements'];
87 87
 }
88 88
 
89 89
 var_dump($totalElements);
Please login to merge, or discard this patch.