1 | <?php |
||
9 | class PasswordManager |
||
10 | { |
||
11 | /** @type array<array> The passwords. */ |
||
12 | private $_passwords; |
||
13 | |||
14 | /** |
||
15 | * Initialize the password manager. |
||
16 | * |
||
17 | * @api |
||
18 | * @param array<array> The passwords. |
||
19 | */ |
||
20 | public function __construct(array $passwords) |
||
24 | |||
25 | /** |
||
26 | * Find all the passwords that match the given application name. |
||
27 | * |
||
28 | * The application name is used as a regex. |
||
29 | * |
||
30 | * @api |
||
31 | * @param string $application The application name. |
||
32 | * @return array<array> The passwords for the applications that match the |
||
33 | * application. |
||
34 | */ |
||
35 | public function matchingApplication($application) |
||
46 | |||
47 | /** |
||
48 | * Add the new application to the password list. |
||
49 | * |
||
50 | * @api |
||
51 | * @param string $name The unique application name. |
||
52 | * @param array $newApplication The application information. |
||
53 | * @return void |
||
54 | */ |
||
55 | public function addPassword($name, array $newApplication) |
||
63 | |||
64 | /** |
||
65 | * Remove the given password by unique name. |
||
66 | * |
||
67 | * @api |
||
68 | * @param string $name The unique application name. |
||
69 | * @return void |
||
70 | */ |
||
71 | public function removePassword($name) |
||
75 | |||
76 | /** |
||
77 | * Replace one set of passwords with a new set. |
||
78 | * |
||
79 | * Removes all the passwords in $old, and adds all the passwords in $new. |
||
80 | * |
||
81 | * @api |
||
82 | * @param array $old The old passwords to replace. |
||
83 | * @param array $new The new passwords to use instead. |
||
84 | * @return void |
||
85 | */ |
||
86 | public function replacePasswords(array $old, array $new) |
||
96 | |||
97 | /** |
||
98 | * Get the passwords. |
||
99 | * |
||
100 | * @api |
||
101 | * @return array<array> The passwords. |
||
102 | */ |
||
103 | public function getPasswords() |
||
107 | |||
108 | /** |
||
109 | * Sort the passwords. |
||
110 | * |
||
111 | * @api |
||
112 | * @return void |
||
113 | */ |
||
114 | public function sortPasswords() |
||
118 | } |
||
119 |