Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7481715
Matrix.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
Matrix.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Endroid\QrCode\Matrix
;
use
Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeEnlarge
;
use
Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeInterface
;
use
Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin
;
use
Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeShrink
;
final
class
Matrix
implements
MatrixInterface
{
/** @var array<int, array<int, int>> */
private
array
$blockValues
=
[];
private
float
$blockSize
;
private
int
$innerSize
;
private
int
$outerSize
;
private
int
$marginLeft
;
private
int
$marginRight
;
/** @param array<array<int>> $blockValues */
public
function
__construct
(
array
$blockValues
,
int
$size
,
int
$margin
,
RoundBlockSizeModeInterface
$roundBlockSizeMode
)
{
$this
->
blockValues
=
$blockValues
;
$this
->
blockSize
=
$size
/
$this
->
getBlockCount
();
$this
->
innerSize
=
$size
;
$this
->
outerSize
=
$size
+
2
*
$margin
;
if
(
$roundBlockSizeMode
instanceof
RoundBlockSizeModeEnlarge
)
{
$this
->
blockSize
=
intval
(
ceil
(
$this
->
blockSize
));
$this
->
innerSize
=
intval
(
$this
->
blockSize
*
$this
->
getBlockCount
());
$this
->
outerSize
=
$this
->
innerSize
+
2
*
$margin
;
}
elseif
(
$roundBlockSizeMode
instanceof
RoundBlockSizeModeShrink
)
{
$this
->
blockSize
=
intval
(
floor
(
$this
->
blockSize
));
$this
->
innerSize
=
intval
(
$this
->
blockSize
*
$this
->
getBlockCount
());
$this
->
outerSize
=
$this
->
innerSize
+
2
*
$margin
;
}
elseif
(
$roundBlockSizeMode
instanceof
RoundBlockSizeModeMargin
)
{
$this
->
blockSize
=
intval
(
floor
(
$this
->
blockSize
));
$this
->
innerSize
=
intval
(
$this
->
blockSize
*
$this
->
getBlockCount
());
}
if
(
$this
->
blockSize
<
1
)
{
throw
new
\Exception
(
'Too much data: increase image dimensions or lower error correction level'
);
}
$this
->
marginLeft
=
intval
((
$this
->
outerSize
-
$this
->
innerSize
)
/
2
);
$this
->
marginRight
=
$this
->
outerSize
-
$this
->
innerSize
-
$this
->
marginLeft
;
}
public
function
getBlockValue
(
int
$rowIndex
,
int
$columnIndex
):
int
{
return
$this
->
blockValues
[
$rowIndex
][
$columnIndex
];
}
public
function
getBlockCount
():
int
{
return
count
(
$this
->
blockValues
[
0
]);
}
public
function
getBlockSize
():
float
{
return
$this
->
blockSize
;
}
public
function
getInnerSize
():
int
{
return
$this
->
innerSize
;
}
public
function
getOuterSize
():
int
{
return
$this
->
outerSize
;
}
public
function
getMarginLeft
():
int
{
return
$this
->
marginLeft
;
}
public
function
getMarginRight
():
int
{
return
$this
->
marginRight
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 23, 12:50 (1 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4b/29/926c934777725b9882f72424a4eb
Default Alt Text
Matrix.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment