1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the "php-ipfs" package. |
7
|
|
|
* |
8
|
|
|
* (c) Robert Schönthal <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace IPFS\Api; |
15
|
|
|
|
16
|
|
|
use IPFS\Annotation\Api as Endpoint; |
17
|
|
|
use IPFS\Command\Command; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Robert Schönthal <[email protected]> |
21
|
|
|
* @autogenerated |
22
|
|
|
* @codeCoverageIgnore |
23
|
|
|
*/ |
24
|
|
View Code Duplication |
final class Pin implements Api |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Pin objects to local storage. |
28
|
|
|
* |
29
|
|
|
* @Endpoint(name="pin:add") |
30
|
|
|
* |
31
|
|
|
* @param string $arg path to object(s) to be pinned |
32
|
|
|
* @param bool $recursive recursively pin the object linked to by the specified object(s) |
33
|
|
|
* @param bool $progress show progress |
34
|
|
|
* |
35
|
|
|
* @return Command |
36
|
|
|
*/ |
37
|
|
|
public function add(string $arg, bool $recursive = true, bool $progress = false): Command |
38
|
|
|
{ |
39
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* List objects pinned to local storage. |
44
|
|
|
* |
45
|
|
|
* @Endpoint(name="pin:ls") |
46
|
|
|
* |
47
|
|
|
* @param string $arg path to object(s) to be listed |
48
|
|
|
* @param string $type the type of pinned keys to list |
49
|
|
|
* @param bool $quiet write just hashes of objects |
50
|
|
|
* |
51
|
|
|
* @return Command |
52
|
|
|
*/ |
53
|
|
|
public function ls(string $arg = null, string $type = 'all', bool $quiet = false): Command |
54
|
|
|
{ |
55
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Remove pinned objects from local storage. |
60
|
|
|
* |
61
|
|
|
* @Endpoint(name="pin:rm") |
62
|
|
|
* |
63
|
|
|
* @param string $arg path to object(s) to be unpinned |
64
|
|
|
* @param bool $recursive recursively unpin the object linked to by the specified object(s) |
65
|
|
|
* |
66
|
|
|
* @return Command |
67
|
|
|
*/ |
68
|
|
|
public function rm(string $arg, bool $recursive = true): Command |
69
|
|
|
{ |
70
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Update a recursive pin. |
75
|
|
|
* |
76
|
|
|
* @Endpoint(name="pin:update") |
77
|
|
|
* |
78
|
|
|
* @param string $arg path to old object |
79
|
|
|
* @param string $arg1 path to new object to be pinned |
80
|
|
|
* @param bool $unpin remove the old pin |
81
|
|
|
* |
82
|
|
|
* @return Command |
83
|
|
|
*/ |
84
|
|
|
public function update(string $arg, string $arg1, bool $unpin = true): Command |
85
|
|
|
{ |
86
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Verify that recursive pins are complete. |
91
|
|
|
* |
92
|
|
|
* @Endpoint(name="pin:verify") |
93
|
|
|
* |
94
|
|
|
* @param bool $verbose also write the hashes of non-broken pins |
95
|
|
|
* @param bool $quiet write just hashes of broken pins |
96
|
|
|
* |
97
|
|
|
* @return Command |
98
|
|
|
*/ |
99
|
|
|
public function verify(bool $verbose = false, bool $quiet = false): Command |
100
|
|
|
{ |
101
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.