PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / S3 / Exception / DeleteMultipleObjectsException.php

DeleteMultipleObjectsException.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/Aws/S3/Exception/DeleteMultipleObjectsException.php

61 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\S3\Exception;
4
5 use Dudlewebs\WPMCS\s3\Aws\HasMonitoringEventsTrait;
6 use Dudlewebs\WPMCS\s3\Aws\MonitoringEventsInterface;
7 /**
8 * Exception thrown when errors occur while deleting objects using a
9 * {@see S3\BatchDelete} object.
10 */
11 class DeleteMultipleObjectsException extends \Exception implements MonitoringEventsInterface
12 {
13 use HasMonitoringEventsTrait;
14 private $deleted = [];
15 private $errors = [];
16 /**
17 * @param array $deleted Array of successfully deleted keys
18 * @param array $errors Array of errors that were encountered
19 */
20 public function __construct(array $deleted, array $errors)
21 {
22 $this->deleted = \array_values($deleted);
23 $this->errors = \array_values($errors);
24 parent::__construct('Unable to delete certain keys when executing a' . ' DeleteMultipleObjects request: ' . self::createMessageFromErrors($errors));
25 }
26 /**
27 * Create a single error message from multiple errors.
28 *
29 * @param array $errors Errors encountered
30 *
31 * @return string
32 */
33 public static function createMessageFromErrors(array $errors)
34 {
35 return "\n- " . \implode("\n- ", \array_map(function ($key) {
36 return \json_encode($key);
37 }, $errors));
38 }
39 /**
40 * Get the errored objects
41 *
42 * @return array Returns an array of associative arrays, each containing
43 * a 'Code', 'Message', and 'Key' key.
44 */
45 public function getErrors()
46 {
47 return $this->errors;
48 }
49 /**
50 * Get the successfully deleted objects
51 *
52 * @return array Returns an array of associative arrays, each containing
53 * a 'Key' and optionally 'DeleteMarker' and
54 * 'DeleterMarkerVersionId'
55 */
56 public function getDeleted()
57 {
58 return $this->deleted;
59 }
60 }
61