* @license http://www.gnu.org/licenses/gpl.html GNU General Public * License (GPL) * @package PEL */ /** * Class for holding signed shorts. * * This class can hold shorts, either just a single short or an array * of shorts. The class will be used to manipulate any of the Exif * tags which has format {@link PelFormat::SSHORT}. * * @author Martin Geisler * @package PEL */ class PelEntrySShort extends PelEntryNumber { /** * Make a new entry that can hold a signed short. * * 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::SSHORT}. * * @param int $value... * the signed short(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 short, that is between -32768 to 32767 * (inclusive). If not, then a {@link PelOverFlowException} will be * thrown. */ public function __construct($tag, $value = null) { $this->tag = $tag; $this->min = - 32768; $this->max = 32767; $this->format = PelFormat::SSHORT; $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 PelConvert::sShortToBytes($number, $order); } }