1 <?php
2
3 namespace PayPal\Api;
4
5 use PayPal\Common\PayPalModel;
6
7 /**
8 * Class Image
9 *
10 * @package PayPal\Api
11 *
12 * @property string image
13 */
14 class Image extends PayPalModel
15 {
16 /**
17 * List of invoices belonging to a merchant.
18 *
19 * @param string $imageBase64String
20 *
21 * @return $this
22 */
23 public function setImage($imageBase64String)
24 {
25 $this->image = $imageBase64String;
26 return $this;
27 }
28
29 /**
30 * Get Image as Base-64 encoded String
31 *
32 * @return string
33 */
34 public function getImage()
35 {
36 return $this->image;
37 }
38
39 /**
40 * Stores the Image to file
41 *
42 * @param string $name File Name
43 * @return string File name
44 */
45 public function saveToFile($name = null)
46 {
47 // Self Generate File Location
48 if (!$name) {
49 $name = uniqid() . '.png';
50 }
51 // Save to File
52 file_put_contents($name, base64_decode($this->getImage()));
53 return $name;
54 }
55
56 }
57