X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Flsolesen%2Fpel%2Fsrc%2FPelEntrySByte.php;fp=vendor%2Flsolesen%2Fpel%2Fsrc%2FPelEntrySByte.php;h=e5a992fb20c6f95d32c0868c8e38c48bd9c77416;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/lsolesen/pel/src/PelEntrySByte.php b/vendor/lsolesen/pel/src/PelEntrySByte.php new file mode 100644 index 000000000..e5a992fb2 --- /dev/null +++ b/vendor/lsolesen/pel/src/PelEntrySByte.php @@ -0,0 +1,99 @@ + + * @license http://www.gnu.org/licenses/gpl.html GNU General Public + * License (GPL) + * @package PEL + */ + +/** + * Class for holding signed bytes. + * + * This class can hold bytes, either just a single byte or an array of + * bytes. The class will be used to manipulate any of the Exif tags + * which has format {@link PelFormat::BYTE}. + * + * @author Martin Geisler + * @package PEL + */ +class PelEntrySByte extends PelEntryNumber +{ + + /** + * Make a new entry that can hold a signed byte. + * + * The method accept several integer arguments. The {@link getValue} + * method will always return an array except for when a single + * integer argument is given here. + * + * @param PelTag $tag + * the tag which this entry represents. This + * should be one of the constants defined in {@link PelTag} + * which has format {@link PelFormat::BYTE}. + * + * @param int $value... + * the byte(s) that this entry will represent. + * The argument passed must obey the same rules as the argument to + * {@link setValue}, namely that it should be within range of a + * signed byte, that is between -128 and 127 (inclusive). If not, + * then a {@link PelOverflowException} will be thrown. + */ + public function __construct($tag, $value = null) + { + $this->tag = $tag; + $this->min = - 128; + $this->max = 127; + $this->format = PelFormat::SBYTE; + + $value = func_get_args(); + array_shift($value); + $this->setValueArray($value); + } + + /** + * Convert a number into bytes. + * + * @param int $number + * the number that should be converted. + * + * @param PelByteOrder $order + * one of {@link PelConvert::LITTLE_ENDIAN} and + * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order. + * + * @return string bytes representing the number given. + */ + public function numberToBytes($number, $order) + { + return chr($number); + } +}