2929 */
3030final class BinaryBitmap
3131{
32-
3332 private $ binarizer ;
3433 private $ matrix ;
3534
36- public function __construct ($ binarizer )
35+ public function __construct (Binarizer $ binarizer )
3736 {
38- if ($ binarizer == null ) {
37+ if ($ binarizer === null ) {
3938 throw new \InvalidArgumentException ("Binarizer must be non-null. " );
4039 }
4140 $ this ->binarizer = $ binarizer ;
4241 }
4342
4443 /**
45- * @return The width of the bitmap.
44+ * @return int The width of the bitmap.
4645 */
4746 public function getWidth ()
4847 {
4948 return $ this ->binarizer ->getWidth ();
5049 }
5150
5251 /**
53- * @return The height of the bitmap.
52+ * @return int The height of the bitmap.
5453 */
5554 public function getHeight ()
5655 {
@@ -66,7 +65,7 @@ public function getHeight()
6665 * @param row An optional preallocated array. If null or too small, it will be ignored.
6766 * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
6867 *
69- * @return The array of bits for this row (true means black).
68+ * @return array The array of bits for this row (true means black).
7069 * @throws NotFoundException if row can't be binarized
7170 */
7271 public function getBlackRow ($ y , $ row )
@@ -91,7 +90,7 @@ public function isCropSupported()
9190 * @param width The width of the rectangle to crop.
9291 * @param height The height of the rectangle to crop.
9392 *
94- * @return A cropped version of this object.
93+ * @return BinaryBitmap A cropped version of this object.
9594 */
9695 public function crop ($ left , $ top , $ width , $ height )
9796 {
@@ -112,7 +111,7 @@ public function isRotateSupported()
112111 * Returns a new object with rotated image data by 90 degrees counterclockwise.
113112 * Only callable if {@link #isRotateSupported()} is true.
114113 *
115- * @return A rotated version of this object.
114+ * @return BinaryBitmap A rotated version of this object.
116115 */
117116 public function rotateCounterClockwise ()
118117 {
@@ -125,7 +124,7 @@ public function rotateCounterClockwise()
125124 * Returns a new object with rotated image data by 45 degrees counterclockwise.
126125 * Only callable if {@link #isRotateSupported()} is true.
127126 *
128- * @return A rotated version of this object.
127+ * @return BinaryBitmap A rotated version of this object.
129128 */
130129 public function rotateCounterClockwise45 ()
131130 {
@@ -139,8 +138,9 @@ public function toString()
139138 try {
140139 return $ this ->getBlackMatrix ()->toString ();
141140 } catch (NotFoundException $ e ) {
142- return "" ;
143141 }
142+
143+ return '' ;
144144 }
145145
146146//@Override
@@ -151,17 +151,17 @@ public function toString()
151151 * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
152152 * fetched using getBlackRow(), so don't mix and match between them.
153153 *
154- * @return The 2D array of bits for the image (true means black).
154+ * @return BitMatrix The 2D array of bits for the image (true means black).
155155 * @throws NotFoundException if image can't be binarized to make a matrix
156156 */
157- public function getBlackMatrix ()
157+ public function getBlackMatrix (): BitMatrix
158158 {
159159// The matrix is created on demand the first time it is requested, then cached. There are two
160160// reasons for this:
161161// 1. This work will never be done if the caller only installs 1D Reader objects, or if a
162162// 1D Reader finds a barcode before the 2D Readers run.
163163// 2. This work will only be done once even if the caller installs multiple 2D Readers.
164- if ($ this ->matrix == null ) {
164+ if ($ this ->matrix === null ) {
165165 $ this ->matrix = $ this ->binarizer ->getBlackMatrix ();
166166 }
167167
0 commit comments