1 | <?php |
||
48 | abstract class AbstractContentPart extends AbstractPart |
||
49 | { |
||
50 | /** |
||
51 | * Media type |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | const MEDIA_TYPE = 'application/octet-stream'; |
||
56 | |||
57 | /** |
||
58 | * Text content |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $content = ''; |
||
63 | |||
64 | /** |
||
65 | * Part constructor |
||
66 | * |
||
67 | * @param AbstractSinglepartHydrator $hydrator Associated hydrator |
||
68 | * @param string $content Part content |
||
69 | */ |
||
70 | 78 | public function __construct(AbstractSinglepartHydrator $hydrator, $content = '') |
|
75 | |||
76 | /** |
||
77 | * Serialize this file part |
||
78 | * |
||
79 | * @return string File part content |
||
80 | */ |
||
81 | 40 | public function __toString() |
|
85 | |||
86 | /** |
||
87 | * Return the media type of this part |
||
88 | * |
||
89 | * @return string Media type |
||
90 | */ |
||
91 | 4 | public function getMediaType() |
|
95 | |||
96 | /** |
||
97 | * Set the contents of a part |
||
98 | * |
||
99 | * @param string $data Contents |
||
100 | * @param array $subparts Subparts |
||
101 | * @return AbstractContentPart New content part |
||
102 | */ |
||
103 | 19 | public function set($data, array $subparts = []) |
|
109 | |||
110 | /** |
||
111 | * Return the part itself |
||
112 | * |
||
113 | * Content parts don't have subparts, so this method will always return the part itself |
||
114 | * |
||
115 | * @param array $subparts Subpart identifiers |
||
116 | * @return PartInterface Self reference |
||
117 | */ |
||
118 | 36 | public function get(array $subparts = []) |
|
123 | |||
124 | /** |
||
125 | * Delegate a method call to a subpart |
||
126 | * |
||
127 | * @param string $method Method nae |
||
128 | * @param array $subparts Subpart identifiers |
||
129 | * @param array $arguments Method arguments |
||
130 | * @return mixed Method result |
||
131 | * @throws InvalidArgumentException If there are subpart identifiers |
||
132 | */ |
||
133 | 30 | public function delegate($method, array $subparts, array $arguments) |
|
145 | } |
||
146 |