PageRenderTime 1646ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/public/packages/ckeditor/plugins/ckfinder/core/connector/php/vendor/microsoft/azure-storage/src/File/Models/ListDirectoriesAndFilesResult.php

https://bitbucket.org/AndreFigueira93/siscon-laravel
PHP | 260 lines | 131 code | 27 blank | 102 comment | 10 complexity | c5e63296d9f344a2e94940272d824a80 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * LICENSE: The MIT License (the "License")
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * https://github.com/azure/azure-storage-php/LICENSE
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. * @package MicrosoftAzure\Storage\File\Models
  18. * @author Azure Storage PHP SDK <dmsh@microsoft.com>
  19. * @copyright 2016 Microsoft Corporation
  20. * @license https://github.com/azure/azure-storage-php/LICENSE
  21. * @link https://github.com/azure/azure-storage-php
  22. */
  23. namespace MicrosoftAzure\Storage\File\Models;
  24. use MicrosoftAzure\Storage\Common\Internal\Resources;
  25. use MicrosoftAzure\Storage\Common\Internal\Utilities;
  26. use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken;
  27. use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait;
  28. /**
  29. * Share to hold list directories and files response object.
  30. *
  31. * @category Microsoft
  32. * @package MicrosoftAzure\Storage\File\Models
  33. * @author Azure Storage PHP SDK <dmsh@microsoft.com>
  34. * @copyright 2016 Microsoft Corporation
  35. * @license https://github.com/azure/azure-storage-php/LICENSE
  36. * @link https://github.com/azure/azure-storage-php
  37. */
  38. class ListDirectoriesAndFilesResult
  39. {
  40. use MarkerContinuationTokenTrait;
  41. private $directories;
  42. private $files;
  43. private $maxResults;
  44. private $accountName;
  45. private $marker;
  46. /**
  47. * Creates ListDirectoriesAndFilesResult object from parsed XML response.
  48. *
  49. * @param array $parsedResponse XML response parsed into array.
  50. * @param string $location Contains the location for the previous
  51. * request.
  52. *
  53. * @internal
  54. *
  55. * @return ListSharesResult
  56. */
  57. public static function create(array $parsedResponse, $location = '')
  58. {
  59. $result = new ListDirectoriesAndFilesResult();
  60. $serviceEndpoint = Utilities::tryGetKeysChainValue(
  61. $parsedResponse,
  62. Resources::XTAG_ATTRIBUTES,
  63. Resources::XTAG_SERVICE_ENDPOINT
  64. );
  65. $result->setAccountName(Utilities::tryParseAccountNameFromUrl(
  66. $serviceEndpoint
  67. ));
  68. $nextMarker = Utilities::tryGetValue(
  69. $parsedResponse,
  70. Resources::QP_NEXT_MARKER
  71. );
  72. if ($nextMarker != null) {
  73. $result->setContinuationToken(
  74. new MarkerContinuationToken(
  75. $nextMarker,
  76. $location
  77. )
  78. );
  79. }
  80. $result->setMaxResults(Utilities::tryGetValue(
  81. $parsedResponse,
  82. Resources::QP_MAX_RESULTS
  83. ));
  84. $result->setMarker(Utilities::tryGetValue(
  85. $parsedResponse,
  86. Resources::QP_MARKER
  87. ));
  88. $entries = Utilities::tryGetValue(
  89. $parsedResponse,
  90. Resources::QP_ENTRIES
  91. );
  92. if (empty($entries)) {
  93. $result->setDirectories(array());
  94. $result->setFiles(array());
  95. } else {
  96. $directoriesArray = Utilities::tryGetValue(
  97. $entries,
  98. Resources::QP_DIRECTORY
  99. );
  100. $filesArray = Utilities::tryGetValue(
  101. $entries,
  102. Resources::QP_FILE
  103. );
  104. $directories = array();
  105. $files = array();
  106. if ($directoriesArray != null) {
  107. if (array_key_exists(Resources::QP_NAME, $directoriesArray)) {
  108. $directoriesArray = [$directoriesArray];
  109. }
  110. foreach ($directoriesArray as $directoryArray) {
  111. $directories[] = Directory::create($directoryArray);
  112. }
  113. }
  114. if ($filesArray != null) {
  115. if (array_key_exists(Resources::QP_NAME, $filesArray)) {
  116. $filesArray = [$filesArray];
  117. }
  118. foreach ($filesArray as $fileArray) {
  119. $files[] = Directory::create($fileArray);
  120. }
  121. }
  122. $result->setDirectories($directories);
  123. $result->setFiles($files);
  124. }
  125. return $result;
  126. }
  127. /**
  128. * Sets Directories.
  129. *
  130. * @param array $directories list of directories.
  131. *
  132. * @return void
  133. */
  134. protected function setDirectories(array $directories)
  135. {
  136. $this->directories = array();
  137. foreach ($directories as $directory) {
  138. $this->directories[] = clone $directory;
  139. }
  140. }
  141. /**
  142. * Gets directories.
  143. *
  144. * @return Directory[]
  145. */
  146. public function getDirectories()
  147. {
  148. return $this->directories;
  149. }
  150. /**
  151. * Sets files.
  152. *
  153. * @param array $files list of files.
  154. *
  155. * @return void
  156. */
  157. protected function setFiles(array $files)
  158. {
  159. $this->files = array();
  160. foreach ($files as $file) {
  161. $this->files[] = clone $file;
  162. }
  163. }
  164. /**
  165. * Gets files.
  166. *
  167. * @return File[]
  168. */
  169. public function getFiles()
  170. {
  171. return $this->files;
  172. }
  173. /**
  174. * Gets max results.
  175. *
  176. * @return string
  177. */
  178. public function getMaxResults()
  179. {
  180. return $this->maxResults;
  181. }
  182. /**
  183. * Sets max results.
  184. *
  185. * @param string $maxResults value.
  186. *
  187. * @return void
  188. */
  189. protected function setMaxResults($maxResults)
  190. {
  191. $this->maxResults = $maxResults;
  192. }
  193. /**
  194. * Gets marker.
  195. *
  196. * @return string
  197. */
  198. public function getMarker()
  199. {
  200. return $this->marker;
  201. }
  202. /**
  203. * Sets marker.
  204. *
  205. * @param string $marker value.
  206. *
  207. * @return void
  208. */
  209. protected function setMarker($marker)
  210. {
  211. $this->marker = $marker;
  212. }
  213. /**
  214. * Gets account name.
  215. *
  216. * @return string
  217. */
  218. public function getAccountName()
  219. {
  220. return $this->accountName;
  221. }
  222. /**
  223. * Sets account name.
  224. *
  225. * @param string $accountName value.
  226. *
  227. * @return void
  228. */
  229. protected function setAccountName($accountName)
  230. {
  231. $this->accountName = $accountName;
  232. }
  233. }