Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / vendor / lsolesen / pel / src / PelJpegComment.php
1 <?php
2
3 /**
4  * PEL: PHP Exif Library.
5  * A library with support for reading and
6  * writing all Exif headers in JPEG and TIFF images using PHP.
7  *
8  * Copyright (C) 2005, 2007 Martin Geisler.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program in the file COPYING; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301 USA
24  */
25 namespace lsolesen\pel;
26
27 /**
28  * Class for dealing with JPEG comments.
29  *
30  * @author Martin Geisler <mgeisler@users.sourceforge.net>
31  * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32  *          License (GPL)
33  * @package PEL
34  */
35
36 /**
37  * Class representing JPEG comments.
38  *
39  * @author Martin Geisler <mgeisler@users.sourceforge.net>
40  * @package PEL
41  */
42 class PelJpegComment extends PelJpegContent
43 {
44
45     /**
46      * The comment.
47      *
48      * @var string
49      */
50     private $comment = '';
51
52     /**
53      * Construct a new JPEG comment.
54      *
55      * The new comment will contain the string given.
56      *
57      * @param string $comment
58      */
59     public function __construct($comment = '')
60     {
61         $this->comment = $comment;
62     }
63
64     /**
65      * Load and parse data.
66      *
67      * This will load the comment from the data window passed.
68      *
69      * @param PelDataWindow $d
70      */
71     public function load(PelDataWindow $d)
72     {
73         $this->comment = $d->getBytes();
74     }
75
76     /**
77      * Update the value with a new comment.
78      *
79      * Any old comment will be overwritten.
80      *
81      * @param string $comment
82      *            the new comment.
83      */
84     public function setValue($comment)
85     {
86         $this->comment = $comment;
87     }
88
89     /**
90      * Get the comment.
91      *
92      * @return string the comment.
93      */
94     public function getValue()
95     {
96         return $this->comment;
97     }
98
99     /**
100      * Turn this comment into bytes.
101      *
102      * @return string bytes representing this comment.
103      */
104     public function getBytes()
105     {
106         return $this->comment;
107     }
108
109     /**
110      * Return a string representation of this object.
111      *
112      * @return string the same as {@link getValue()}.
113      */
114     public function __toString()
115     {
116         return $this->getValue();
117     }
118 }