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 Name implements Api |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Publish IPNS names. |
28
|
|
|
* |
29
|
|
|
* @Endpoint(name="name:publish") |
30
|
|
|
* |
31
|
|
|
* @param string $arg ipfs path of the object to be published |
32
|
|
|
* @param bool $resolve resolve given path before publishing |
33
|
|
|
* @param string $lifetime time duration that the record will be valid for |
34
|
|
|
* @param string $ttl time duration this record should be cached for (caution: experimental) |
35
|
|
|
* @param string $key name of the key to be used or a valid PeerID, as listed by ‘ipfs key list -l’ |
36
|
|
|
* |
37
|
|
|
* @return Command |
38
|
|
|
*/ |
39
|
|
|
public function publish(string $arg, bool $resolve = true, string $lifetime = '24h', string $ttl = null, string $key = 'self'): Command |
40
|
|
|
{ |
41
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Cancel a name subscription. |
46
|
|
|
* |
47
|
|
|
* @Endpoint(name="name:pubsub:cancel") |
48
|
|
|
* |
49
|
|
|
* @param string $arg name to cancel the subscription for |
50
|
|
|
* |
51
|
|
|
* @return Command |
52
|
|
|
*/ |
53
|
|
|
public function pubsubCancel(string $arg): Command |
54
|
|
|
{ |
55
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Query the state of IPNS pubsub. |
60
|
|
|
* |
61
|
|
|
* @Endpoint(name="name:pubsub:state") |
62
|
|
|
* |
63
|
|
|
* @return Command |
64
|
|
|
*/ |
65
|
|
|
public function pubsubState(): Command |
66
|
|
|
{ |
67
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Show current name subscriptions. |
72
|
|
|
* |
73
|
|
|
* @Endpoint(name="name:pubsub:subs") |
74
|
|
|
* |
75
|
|
|
* @return Command |
76
|
|
|
*/ |
77
|
|
|
public function pubsubSubs(): Command |
78
|
|
|
{ |
79
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Resolve IPNS names. |
84
|
|
|
* |
85
|
|
|
* @Endpoint(name="name:resolve") |
86
|
|
|
* |
87
|
|
|
* @param string $arg the IPNS name to resolve |
88
|
|
|
* @param bool $recursive resolve until the result is not an IPNS name |
89
|
|
|
* @param bool $nocache do not use cached entries |
90
|
|
|
* @param uint $dhtRecordCount number of records to request for DHT resolution |
91
|
|
|
* @param string $dhtTimeout max time to collect values during DHT resolution eg “30s” |
92
|
|
|
* |
93
|
|
|
* @return Command |
94
|
|
|
*/ |
95
|
|
|
public function resolve(string $arg = null, bool $recursive = false, bool $nocache = false, uint $dhtRecordCount = null, string $dhtTimeout = null): Command |
96
|
|
|
{ |
97
|
|
|
return new Command(__METHOD__, get_defined_vars()); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
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.