PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.25
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.25
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / Attachment / Attachment.php

Attachment.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.25, at vendor_prefixed/sentry/sentry/src/Attachment/Attachment.php

66 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry\Attachment;
5
6 abstract class Attachment
7 {
8 private const DEFAULT_CONTENT_TYPE = 'application/octet-stream';
9 /**
10 * @var string
11 */
12 private $filename;
13 /**
14 * @var string
15 */
16 private $contentType;
17 public function __construct(string $filename, string $contentType)
18 {
19 $this->filename = $filename;
20 $this->contentType = $contentType;
21 }
22 public function getFilename() : string
23 {
24 return $this->filename;
25 }
26 public function getContentType() : string
27 {
28 return $this->contentType;
29 }
30 /**
31 * Returns the size in bytes for the attachment. This method should aim to use a low overhead
32 * way of determining the size because it will be called more than once.
33 * For example, for file attachments it should read the file size from the filesystem instead of
34 * reading the file in memory and then calculating the length.
35 * If no low overhead way exists, then the result should be cached so that calling it multiple times
36 * does not decrease performance.
37 *
38 * @return int the size in bytes or null if the length could not be determined, for example if the file
39 * does not exist
40 */
41 public abstract function getSize() : ?int;
42 /**
43 * Fetches and returns the data. Calling this can have a non-trivial impact on memory usage, depending
44 * on the type and size of attachment.
45 *
46 * @return string the content as bytes or null if the content could not be retrieved, for example if the file
47 * does not exist
48 */
49 public abstract function getData() : ?string;
50 /**
51 * Creates a new attachment representing a file referenced by a path.
52 * The file is not validated and the content is not read when creating the attachment.
53 */
54 public static function fromFile(string $path, string $contentType = self::DEFAULT_CONTENT_TYPE) : Attachment
55 {
56 return new FileAttachment($path, $contentType);
57 }
58 /**
59 * Creates a new attachment representing a slice of bytes that lives in memory.
60 */
61 public static function fromBytes(string $filename, string $data, string $contentType = self::DEFAULT_CONTENT_TYPE) : Attachment
62 {
63 return new ByteAttachment($filename, $contentType, $data);
64 }
65 }
66