ac736c118bc6b681736553c2a1e02e2ca0533e40
[yaffs-website] / vendor / lsolesen / pel / src / PelEntryByte.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) 2004, 2005, 2006, 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  * Classes used to hold bytes, both signed and unsigned.
29  * The {@link
30  * PelEntryWindowsString} class is used to manipulate strings in the
31  * format Windows XP needs.
32  *
33  * @author Martin Geisler <mgeisler@users.sourceforge.net>
34  * @license http://www.gnu.org/licenses/gpl.html GNU General Public
35  *          License (GPL)
36  * @package PEL
37  */
38
39 /**
40  * Class for holding unsigned bytes.
41  *
42  * This class can hold bytes, either just a single byte or an array of
43  * bytes. The class will be used to manipulate any of the Exif tags
44  * which has format {@link PelFormat::BYTE}.
45  *
46  * @author Martin Geisler <mgeisler@users.sourceforge.net>
47  * @package PEL
48  */
49 class PelEntryByte extends PelEntryNumber
50 {
51
52     /**
53      * Make a new entry that can hold an unsigned byte.
54      *
55      * The method accept several integer arguments. The {@link
56      * getValue} method will always return an array except for when a
57      * single integer argument is given here.
58      *
59      * @param PelTag $tag
60      *            the tag which this entry represents. This
61      *            should be one of the constants defined in {@link PelTag}
62      *            which has format {@link PelFormat::BYTE}.
63      *
64      * @param int $value...
65      *            the byte(s) that this entry will represent.
66      *            The argument passed must obey the same rules as the argument to
67      *            {@link setValue}, namely that it should be within range of an
68      *            unsigned byte, that is between 0 and 255 (inclusive). If not,
69      *            then a {@link PelOverflowException} will be thrown.
70      */
71     public function __construct($tag, $value = null)
72     {
73         $this->tag = $tag;
74         $this->min = 0;
75         $this->max = 255;
76         $this->format = PelFormat::BYTE;
77
78         $value = func_get_args();
79         array_shift($value);
80         $this->setValueArray($value);
81     }
82
83     /**
84      * Convert a number into bytes.
85      *
86      * @param int $number
87      *            the number that should be converted.
88      *
89      * @param PelByteOrder $order
90      *            one of {@link PelConvert::LITTLE_ENDIAN} and
91      *            {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
92      *
93      * @return string bytes representing the number given.
94      */
95     public function numberToBytes($number, $order)
96     {
97         return chr($number);
98     }
99 }