1 | <?php |
||
17 | class File extends PublicKeyStore { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $file; |
||
22 | |||
23 | /** |
||
24 | * @param string $file Valid, read and writable file |
||
25 | * @throws Exception if the file does not exist or not writable |
||
26 | */ |
||
27 | public function __construct($file) { |
||
28 | if(false === is_writable($file)) { |
||
29 | throw new Exception('file '.$file.' does not exist or is not writable'); |
||
30 | } |
||
31 | $this->file = $file; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * return null if the public key not found in the store |
||
36 | * @param string $threemaId |
||
37 | * @return null|string |
||
38 | * @throws Exception |
||
39 | */ |
||
40 | function findPublicKey($threemaId) { |
||
60 | |||
61 | /** |
||
62 | * save a public key |
||
63 | * @param string $threemaId |
||
64 | * @param string $publicKey |
||
65 | * @return bool |
||
66 | */ |
||
67 | function savePublicKey($threemaId, $publicKey) { |
||
70 | |||
71 | /** |
||
72 | * Initialize a new File Public Key Store |
||
73 | * @param string $path the file will be created it it does not exist |
||
74 | * @return File |
||
75 | */ |
||
76 | public static function create($path) { |
||
84 | } |
||
85 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.