1 | <?php |
||
9 | abstract class CloudBucket extends SS_Object |
||
10 | { |
||
11 | const BASE_URL = 'BaseURL'; |
||
12 | const SECURE_URL = 'SecureURL'; |
||
13 | const LOCAL_COPY = 'LocalCopy'; |
||
14 | const TYPE = 'Type'; |
||
15 | |||
16 | const LINK_SMART = 0; |
||
17 | const LINK_HTTP = 1; |
||
18 | const LINK_HTTPS = 2; |
||
19 | // just to keep the same language |
||
20 | const LINK_BASE = 1; |
||
21 | const LINK_SECURE = 2; |
||
22 | |||
23 | /** @var string $localPath - local path being replaced (e.g. assets/Uploads) */ |
||
24 | protected $localPath; |
||
25 | |||
26 | /** @var array $baseURL - CDN url(s) */ |
||
27 | protected $baseURL; |
||
28 | |||
29 | /** @var int $baseUrlIndex - last index sent if more than one base */ |
||
30 | protected $baseUrlIndex = 0; |
||
31 | |||
32 | /** @var array $secureURL - CDN url(s) for https (optional) */ |
||
33 | protected $secureURL; |
||
34 | |||
35 | /** @var int $secureUrlIndex - last index sent if more than one base */ |
||
36 | protected $secureUrlIndex = 0; |
||
37 | |||
38 | /** @var array $config */ |
||
39 | protected $config; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * @param File $f |
||
44 | */ |
||
45 | abstract public function put(File $f); |
||
46 | |||
47 | |||
48 | /** |
||
49 | * NOTE: This method must handle string filenames as well |
||
50 | * for the purpose of deleting cached resampled images. |
||
51 | * @param File|string $f |
||
52 | */ |
||
53 | abstract public function delete($f); |
||
54 | |||
55 | |||
56 | /** |
||
57 | * @param File $f |
||
58 | * @param string $beforeName - contents of the Filename property (i.e. relative to site root) |
||
59 | * @param string $afterName - contents of the Filename property (i.e. relative to site root) |
||
60 | */ |
||
61 | abstract public function rename(File $f, $beforeName, $afterName); |
||
62 | |||
63 | |||
64 | /** |
||
65 | * @param File $f |
||
66 | * @return string |
||
67 | */ |
||
68 | abstract public function getContents(File $f); |
||
69 | |||
70 | |||
71 | /** |
||
72 | * @param string $path |
||
73 | * @param array $cfg |
||
74 | */ |
||
75 | public function __construct($path, array $cfg=array()) |
||
87 | |||
88 | |||
89 | /** |
||
90 | * @param string|array $paths |
||
91 | * @return array |
||
92 | */ |
||
93 | protected function scrubBasePath($paths) |
||
107 | |||
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getBaseURL() |
||
116 | |||
117 | |||
118 | /** |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getSecureURL() |
||
125 | |||
126 | |||
127 | /** |
||
128 | * Given an array property, returns the next element |
||
129 | * from it and increments an index field |
||
130 | * @param string $field |
||
131 | * @return string |
||
132 | */ |
||
133 | protected function roundRobinGet($field) |
||
145 | |||
146 | |||
147 | /** |
||
148 | * @param File|string $f - the string should be the Filename field of a File |
||
149 | * @param int $linkType [optional] |
||
150 | * @return string |
||
151 | */ |
||
152 | public function getLinkFor($f, $linkType = self::LINK_SMART) |
||
187 | |||
188 | |||
189 | /** |
||
190 | * This version just returns a normal link. I'm assuming most |
||
191 | * buckets will implement this but I want it to be optional. |
||
192 | * @param File|string $f |
||
193 | * @param int $expires [optional] - Expiration time in seconds |
||
194 | * @return string |
||
195 | */ |
||
196 | public function getTemporaryLinkFor($f, $expires=3600) |
||
200 | |||
201 | |||
202 | /** |
||
203 | * Returns the full path and filename, relative to the BaseURL |
||
204 | * @param File|string $f |
||
205 | * @return string |
||
206 | */ |
||
207 | public function getRelativeLinkFor($f) |
||
212 | |||
213 | |||
214 | /** |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function isLocalCopyEnabled() |
||
221 | } |
||
222 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.