code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
protected function getByteStream($items) {
$bstream = $this->getBitStream($items);
return $this->bitstreamToByte($bstream);
}
|
Pack all bit streams padding bits into a byte array.
@param int $items
@return array padded merged byte stream
|
getByteStream
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function allocate($setLength) {
return array_fill(0, $setLength, 0);
}
|
Return an array with zeros
@param int $setLength array size
@return array
|
allocate
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function newFromNum($bits, $num) {
$bstream = $this->allocate($bits);
$mask = 1 << ($bits - 1);
for ($i=0; $i<$bits; ++$i) {
if ($num & $mask) {
$bstream[$i] = 1;
} else {
$bstream[$i] = 0;
}
$mask = $mask >> 1;
}
return $bstream;
}
|
Return new bitstream from number
@param int $bits number of bits
@param int $num number
@return array bitstream
|
newFromNum
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function newFromBytes($size, $data) {
$bstream = $this->allocate($size * 8);
$p=0;
for ($i=0; $i<$size; ++$i) {
$mask = 0x80;
for ($j=0; $j<8; ++$j) {
if ($data[$i] & $mask) {
$bstream[$p] = 1;
} else {
$bstream[$p] = 0;
}
$p++;
$mask = $mask >> 1;
}
}
return $bstream;
}
|
Return new bitstream from bytes
@param int $size size
@param array $data bytes
@return array bitstream
|
newFromBytes
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function appendBitstream($bitstream, $append) {
if ((!is_array($append)) OR (count($append) == 0)) {
return $bitstream;
}
if (count($bitstream) == 0) {
return $append;
}
return array_values(array_merge($bitstream, $append));
}
|
Append one bitstream to another
@param array $bitstream original bitstream
@param array $append bitstream to append
@return array bitstream
|
appendBitstream
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function appendNum($bitstream, $bits, $num) {
if ($bits == 0) {
return 0;
}
$b = $this->newFromNum($bits, $num);
return $this->appendBitstream($bitstream, $b);
}
|
Append one bitstream created from number to another
@param array $bitstream original bitstream
@param int $bits number of bits
@param int $num number
@return array bitstream
|
appendNum
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function appendBytes($bitstream, $size, $data) {
if ($size == 0) {
return 0;
}
$b = $this->newFromBytes($size, $data);
return $this->appendBitstream($bitstream, $b);
}
|
Append one bitstream created from bytes to another
@param array $bitstream original bitstream
@param int $size size
@param array $data bytes
@return array bitstream
|
appendBytes
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function bitstreamToByte($bstream) {
$size = count($bstream);
if ($size == 0) {
return array();
}
$data = array_fill(0, (int)(($size + 7) / 8), 0);
$bytes = (int)($size / 8);
$p = 0;
for ($i=0; $i<$bytes; $i++) {
$v = 0;
for ($j=0; $j<8; $j++) {
$v = $v << 1;
$v |= $bstream[$p];
$p++;
}
$data[$i] = $v;
}
if ($size & 7) {
$v = 0;
for ($j=0; $j<($size & 7); $j++) {
$v = $v << 1;
$v |= $bstream[$p];
$p++;
}
$data[$bytes] = $v;
}
return $data;
}
|
Convert bitstream to bytes
@param array $bitstream original bitstream
@return array of bytes
|
bitstreamToByte
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) {
$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
return $srctab;
}
|
Replace a value on the array at the specified position
@param array $srctab
@param int $x X position
@param int $y Y position
@param string $repl value to replace
@param int $replLen length of the repl string
@return array srctab
|
qrstrset
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getDataLength($version, $level) {
return $this->capacity[$version][QRCAP_WORDS] - $this->capacity[$version][QRCAP_EC][$level];
}
|
Return maximum data code length (bytes) for the version.
@param int $version version
@param int $level error correction level
@return int maximum size (bytes)
|
getDataLength
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getECCLength($version, $level){
return $this->capacity[$version][QRCAP_EC][$level];
}
|
Return maximum error correction code length (bytes) for the version.
@param int $version version
@param int $level error correction level
@return int ECC size (bytes)
|
getECCLength
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getWidth($version) {
return $this->capacity[$version][QRCAP_WIDTH];
}
|
Return the width of the symbol for the version.
@param int $version version
@return int width
|
getWidth
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getRemainder($version) {
return $this->capacity[$version][QRCAP_REMINDER];
}
|
Return the numer of remainder bits.
@param int $version version
@return int number of remainder bits
|
getRemainder
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getMinimumVersion($size, $level) {
for ($i=1; $i <= QRSPEC_VERSION_MAX; ++$i) {
$words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level];
if ($words >= $size) {
return $i;
}
}
return -1;
}
|
Return a version number that satisfies the input code length.
@param int $size input code length (byte)
@param int $level error correction level
@return int version number
|
getMinimumVersion
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function lengthIndicator($mode, $version) {
if ($mode == QR_MODE_ST) {
return 0;
}
if ($version <= 9) {
$l = 0;
} elseif ($version <= 26) {
$l = 1;
} else {
$l = 2;
}
return $this->lengthTableBits[$mode][$l];
}
|
Return the size of length indicator for the mode and version.
@param int $mode encoding mode
@param int $version version
@return int the size of the appropriate length indicator (bits).
|
lengthIndicator
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function maximumWords($mode, $version) {
if ($mode == QR_MODE_ST) {
return 3;
}
if ($version <= 9) {
$l = 0;
} else if ($version <= 26) {
$l = 1;
} else {
$l = 2;
}
$bits = $this->lengthTableBits[$mode][$l];
$words = (1 << $bits) - 1;
if ($mode == QR_MODE_KJ) {
$words *= 2; // the number of bytes is required
}
return $words;
}
|
Return the maximum length for the mode and version.
@param int $mode encoding mode
@param int $version version
@return int the maximum length (bytes)
|
maximumWords
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getEccSpec($version, $level, $spec) {
if (count($spec) < 5) {
$spec = array(0, 0, 0, 0, 0);
}
$b1 = $this->eccTable[$version][$level][0];
$b2 = $this->eccTable[$version][$level][1];
$data = $this->getDataLength($version, $level);
$ecc = $this->getECCLength($version, $level);
if ($b2 == 0) {
$spec[0] = $b1;
$spec[1] = (int)($data / $b1);
$spec[2] = (int)($ecc / $b1);
$spec[3] = 0;
$spec[4] = 0;
} else {
$spec[0] = $b1;
$spec[1] = (int)($data / ($b1 + $b2));
$spec[2] = (int)($ecc / ($b1 + $b2));
$spec[3] = $b2;
$spec[4] = $spec[1] + 1;
}
return $spec;
}
|
Return an array of ECC specification.
@param int $version version
@param int $level error correction level
@param array $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code}
@return array spec
|
getEccSpec
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function putAlignmentMarker($frame, $ox, $oy) {
$finder = array(
"\xa1\xa1\xa1\xa1\xa1",
"\xa1\xa0\xa0\xa0\xa1",
"\xa1\xa0\xa1\xa0\xa1",
"\xa1\xa0\xa0\xa0\xa1",
"\xa1\xa1\xa1\xa1\xa1"
);
$yStart = $oy - 2;
$xStart = $ox - 2;
for ($y=0; $y < 5; $y++) {
$frame = $this->qrstrset($frame, $xStart, $yStart+$y, $finder[$y]);
}
return $frame;
}
|
Put an alignment marker.
@param array $frame frame
@param int $width width
@param int $ox X center coordinate of the pattern
@param int $oy Y center coordinate of the pattern
@return array frame
|
putAlignmentMarker
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function putAlignmentPattern($version, $frame, $width) {
if ($version < 2) {
return $frame;
}
$d = $this->alignmentPattern[$version][1] - $this->alignmentPattern[$version][0];
if ($d < 0) {
$w = 2;
} else {
$w = (int)(($width - $this->alignmentPattern[$version][0]) / $d + 2);
}
if ($w * $w - 3 == 1) {
$x = $this->alignmentPattern[$version][0];
$y = $this->alignmentPattern[$version][0];
$frame = $this->putAlignmentMarker($frame, $x, $y);
return $frame;
}
$cx = $this->alignmentPattern[$version][0];
$wo = $w - 1;
for ($x=1; $x < $wo; ++$x) {
$frame = $this->putAlignmentMarker($frame, 6, $cx);
$frame = $this->putAlignmentMarker($frame, $cx, 6);
$cx += $d;
}
$cy = $this->alignmentPattern[$version][0];
for ($y=0; $y < $wo; ++$y) {
$cx = $this->alignmentPattern[$version][0];
for ($x=0; $x < $wo; ++$x) {
$frame = $this->putAlignmentMarker($frame, $cx, $cy);
$cx += $d;
}
$cy += $d;
}
return $frame;
}
|
Put an alignment pattern.
@param int $version version
@param array $fram frame
@param int $width width
@return array frame
|
putAlignmentPattern
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getVersionPattern($version) {
if (($version < 7) OR ($version > QRSPEC_VERSION_MAX)) {
return 0;
}
return $this->versionPattern[($version - 7)];
}
|
Return BCH encoded version information pattern that is used for the symbol of version 7 or greater. Use lower 18 bits.
@param int $version version
@return BCH encoded version information pattern
|
getVersionPattern
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function getFormatInfo($mask, $level) {
if (($mask < 0) OR ($mask > 7)) {
return 0;
}
if (($level < 0) OR ($level > 3)) {
return 0;
}
return $this->formatInfo[$level][$mask];
}
|
Return BCH encoded format information pattern.
@param array $mask
@param int $level error correction level
@return BCH encoded format information pattern
|
getFormatInfo
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function putFinderPattern($frame, $ox, $oy) {
$finder = array(
"\xc1\xc1\xc1\xc1\xc1\xc1\xc1",
"\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
"\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
"\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
"\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
"\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
"\xc1\xc1\xc1\xc1\xc1\xc1\xc1"
);
for ($y=0; $y < 7; $y++) {
$frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]);
}
return $frame;
}
|
Put a finder pattern.
@param array $frame frame
@param int $width width
@param int $ox X center coordinate of the pattern
@param int $oy Y center coordinate of the pattern
@return array frame
|
putFinderPattern
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function createFrame($version) {
$width = $this->capacity[$version][QRCAP_WIDTH];
$frameLine = str_repeat ("\0", $width);
$frame = array_fill(0, $width, $frameLine);
// Finder pattern
$frame = $this->putFinderPattern($frame, 0, 0);
$frame = $this->putFinderPattern($frame, $width - 7, 0);
$frame = $this->putFinderPattern($frame, 0, $width - 7);
// Separator
$yOffset = $width - 7;
for ($y=0; $y < 7; ++$y) {
$frame[$y][7] = "\xc0";
$frame[$y][$width - 8] = "\xc0";
$frame[$yOffset][7] = "\xc0";
++$yOffset;
}
$setPattern = str_repeat("\xc0", 8);
$frame = $this->qrstrset($frame, 0, 7, $setPattern);
$frame = $this->qrstrset($frame, $width-8, 7, $setPattern);
$frame = $this->qrstrset($frame, 0, $width - 8, $setPattern);
// Format info
$setPattern = str_repeat("\x84", 9);
$frame = $this->qrstrset($frame, 0, 8, $setPattern);
$frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8);
$yOffset = $width - 8;
for ($y=0; $y < 8; ++$y,++$yOffset) {
$frame[$y][8] = "\x84";
$frame[$yOffset][8] = "\x84";
}
// Timing pattern
$wo = $width - 15;
for ($i=1; $i < $wo; ++$i) {
$frame[6][7+$i] = chr(0x90 | ($i & 1));
$frame[7+$i][6] = chr(0x90 | ($i & 1));
}
// Alignment pattern
$frame = $this->putAlignmentPattern($version, $frame, $width);
// Version information
if ($version >= 7) {
$vinf = $this->getVersionPattern($version);
$v = $vinf;
for ($x=0; $x<6; ++$x) {
for ($y=0; $y<3; ++$y) {
$frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
$v = $v >> 1;
}
}
$v = $vinf;
for ($y=0; $y<6; ++$y) {
for ($x=0; $x<3; ++$x) {
$frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
$v = $v >> 1;
}
}
}
// and a little bit...
$frame[$width - 8][8] = "\x81";
return $frame;
}
|
Return a copy of initialized frame.
@param int $version version
@return Array of unsigned char.
|
createFrame
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function newFrame($version) {
if (($version < 1) OR ($version > QRSPEC_VERSION_MAX)) {
return NULL;
}
if (!isset($this->frames[$version])) {
$this->frames[$version] = $this->createFrame($version);
}
if (is_null($this->frames[$version])) {
return NULL;
}
return $this->frames[$version];
}
|
Set new frame for the specified version.
@param int $version version
@return Array of unsigned char.
|
newFrame
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsBlockNum($spec) {
return ($spec[0] + $spec[3]);
}
|
Return block number 0
@param array $spec
@return int value
|
rsBlockNum
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsBlockNum1($spec) {
return $spec[0];
}
|
Return block number 1
@param array $spec
@return int value
|
rsBlockNum1
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsDataCodes1($spec) {
return $spec[1];
}
|
Return data codes 1
@param array $spec
@return int value
|
rsDataCodes1
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsEccCodes1($spec) {
return $spec[2];
}
|
Return ecc codes 1
@param array $spec
@return int value
|
rsEccCodes1
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsBlockNum2($spec) {
return $spec[3];
}
|
Return block number 2
@param array $spec
@return int value
|
rsBlockNum2
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsDataCodes2($spec) {
return $spec[4];
}
|
Return data codes 2
@param array $spec
@return int value
|
rsDataCodes2
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsEccCodes2($spec) {
return $spec[2];
}
|
Return ecc codes 2
@param array $spec
@return int value
|
rsEccCodes2
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsDataLength($spec) {
return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]);
}
|
Return data length
@param array $spec
@return int value
|
rsDataLength
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function rsEccLength($spec) {
return ($spec[0] + $spec[3]) * $spec[2];
}
|
Return ecc length
@param array $spec
@return int value
|
rsEccLength
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function modnn($rs, $x) {
while ($x >= $rs['nn']) {
$x -= $rs['nn'];
$x = ($x >> $rs['mm']) + ($x & $rs['nn']);
}
return $x;
}
|
modnn
@param array RS values
@param int $x X position
@return int X osition
|
modnn
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
protected function encode_rs_char($rs, $data, $parity) {
$MM =& $rs['mm']; // bits per symbol
$NN =& $rs['nn']; // the total number of symbols in a RS block
$ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
$INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
$GENPOLY =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form
$NROOTS =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block
$FCR =& $rs['fcr']; // first consecutive root, index form
$PRIM =& $rs['prim']; // primitive element, index form
$IPRIM =& $rs['iprim']; // prim-th root of 1, index form
$PAD =& $rs['pad']; // the number of pad symbols in a block
$A0 =& $NN;
$parity = array_fill(0, $NROOTS, 0);
for ($i=0; $i < ($NN - $NROOTS - $PAD); $i++) {
$feedback = $INDEX_OF[$data[$i] ^ $parity[0]];
if ($feedback != $A0) {
// feedback term is non-zero
// This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
// always be for the polynomials constructed by init_rs()
$feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback);
for ($j=1; $j < $NROOTS; ++$j) {
$parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])];
}
}
// Shift
array_shift($parity);
if ($feedback != $A0) {
array_push($parity, $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[0])]);
} else {
array_push($parity, 0);
}
}
return $parity;
}
|
Encode a Reed-Solomon codec and returns the parity array
@param array $rs RS values
@param array $data data
@param array $parity parity
@return parity array
|
encode_rs_char
|
php
|
wizwizdev/wizwizxui-timebot
|
phpqrcode/bindings/tcpdf/qrcode.php
|
https://github.com/wizwizdev/wizwizxui-timebot/blob/master/phpqrcode/bindings/tcpdf/qrcode.php
|
MIT
|
public function setCsvFilter($filter)
{
$this->csvFilter = $filter;
}
|
Set csv filter
@param callable $filter
|
setCsvFilter
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/CsvFileObject.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/CsvFileObject.php
|
MIT
|
public function __construct(ExporterConfig $config)
{
$this->config = $config;
}
|
Return new Exporter object
@param ExporterConfig $config
|
__construct
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Exporter.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Exporter.php
|
MIT
|
private function checkRowConsistency($row)
{
if ( $this->strict === false ) {
return;
}
$current = count($row);
if ( $this->rowConsistency === null ) {
$this->rowConsistency = $current;
}
if ( $current !== $this->rowConsistency ) {
throw new StrictViolationException();
}
$this->rowConsistency = $current;
}
|
Check if the column count is consistent with comparing other rows
@param array|\Countable $row
@throws Exception\StrictViolationException
|
checkRowConsistency
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Exporter.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Exporter.php
|
MIT
|
public function setEnclosure($enclosure)
{
$this->enclosure = $enclosure;
return $this;
}
|
Set enclosure
@param string $enclosure
@return ExporterConfig
|
setEnclosure
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function setEscape($escape)
{
$this->escape = $escape;
return $this;
}
|
Set escape
@param string $escape
@return ExporterConfig
|
setEscape
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function setNewline($newline)
{
$this->newline = $newline;
return $this;
}
|
Set newline
@param string $newline
@return ExporterConfig
|
setNewline
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function setFromCharset($fromCharset)
{
$this->fromCharset = $fromCharset;
return $this;
}
|
Set from-character set
@param string $fromCharset
@return ExporterConfig
|
setFromCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function getFromCharset()
{
return $this->fromCharset;
}
|
Return from-character set
@return string
|
getFromCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function setToCharset($toCharset)
{
$this->toCharset = $toCharset;
return $this;
}
|
Set to-character set
@param string $toCharset
@return ExporterConfig
|
setToCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function getToCharset()
{
return $this->toCharset;
}
|
Return to-character set
@return string
|
getToCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function setFileMode($fileMode)
{
$this->fileMode = $fileMode;
return $this;
}
|
Set file mode
@param string $fileMode
@return ExporterConfig
|
setFileMode
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function setColumnHeaders(array $columnHeaders)
{
$this->columnHeaders = $columnHeaders;
return $this;
}
|
Set the column headers.
@param array $columnHeaders
@return ExporterConfig
|
setColumnHeaders
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function getColumnHeaders()
{
return $this->columnHeaders;
}
|
Get the column headers.
@return array
|
getColumnHeaders
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/ExporterConfig.php
|
MIT
|
public function current()
{
return call_user_func($this->callable, $this->data->current());
}
|
(PHP 5 >= 5.0.0)<br/>
Return the current element
@link http://php.net/manual/en/iterator.current.php
@return mixed Can return any type.
|
current
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
MIT
|
public function next()
{
$this->data->next();
}
|
(PHP 5 >= 5.0.0)<br/>
Move forward to next element
@link http://php.net/manual/en/iterator.next.php
@return void Any returned value is ignored.
|
next
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
MIT
|
public function key()
{
return $this->data->key();
}
|
(PHP 5 >= 5.0.0)<br/>
Return the key of the current element
@link http://php.net/manual/en/iterator.key.php
@return mixed scalar on success, or null on failure.
|
key
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
MIT
|
public function valid()
{
return $this->data->valid();
}
|
(PHP 5 >= 5.0.0)<br/>
Checks if current position is valid
@link http://php.net/manual/en/iterator.valid.php
@return boolean The return value will be casted to boolean and then evaluated.
Returns true on success or false on failure.
|
valid
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
MIT
|
public function rewind()
{
$this->data->rewind();
}
|
(PHP 5 >= 5.0.0)<br/>
Rewind the Iterator to the first element
@link http://php.net/manual/en/iterator.rewind.php
@return void Any returned value is ignored.
|
rewind
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/CallbackCollection.php
|
MIT
|
public function current()
{
return $this->stmt->fetch(PDO::FETCH_ASSOC);
}
|
(PHP 5 >= 5.0.0)<br/>
Return the current element
@link http://php.net/manual/en/iterator.current.php
@return mixed Can return any type.
|
current
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
MIT
|
public function next()
{
$this->current++;
}
|
(PHP 5 >= 5.0.0)<br/>
Move forward to next element
@link http://php.net/manual/en/iterator.next.php
@return void Any returned value is ignored.
|
next
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
MIT
|
public function key()
{
$this->current;
}
|
(PHP 5 >= 5.0.0)<br/>
Return the key of the current element
@link http://php.net/manual/en/iterator.key.php
@return mixed scalar on success, or null on failure.
|
key
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
MIT
|
public function valid()
{
return ($this->rowCount > $this->current);
}
|
(PHP 5 >= 5.0.0)<br/>
Checks if current position is valid
@link http://php.net/manual/en/iterator.valid.php
@return boolean The return value will be casted to boolean and then evaluated.
Returns true on success or false on failure.
|
valid
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
MIT
|
public function rewind()
{
$this->stmt->execute();
$this->current = 0;
}
|
(PHP 5 >= 5.0.0)<br/>
Rewind the Iterator to the first element
@link http://php.net/manual/en/iterator.rewind.php
@return void Any returned value is ignored.
|
rewind
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Standard/Collection/PdoCollection.php
|
MIT
|
public function testExportsThrowsIOException()
{
$exporter = $this->getMock('Goodby\CSV\Export\Protocol\ExporterInterface');
$exporter
->expects($this->once())
->method('export')
->will($this->throwException(new IOException('Unable to write')));
$exporter->export('/path/to/file.csv', array(
array('ID', 'name', 'email'),
array('1', 'alice', '[email protected]'),
array('2', 'bob', '[email protected]'),
));
}
|
@expectedException \Goodby\CSV\Export\Protocol\Exception\IOException
|
testExportsThrowsIOException
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Tests/Protocol/ExporterInterfaceTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Tests/Protocol/ExporterInterfaceTest.php
|
MIT
|
public function testStrict()
{
$config = new ExporterConfig();
$exporter = new Exporter($config);
$exporter->export('vfs://output/data.csv', array(
array('a', 'b', 'c'),
array('a', 'b', 'c'),
array('a', 'b'),
));
}
|
@expectedException \Goodby\CSV\Export\Standard\Exception\StrictViolationException
|
testStrict
|
php
|
goodby/csv
|
src/Goodby/CSV/Export/Tests/Standard/Join/ExporterTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Export/Tests/Standard/Join/ExporterTest.php
|
MIT
|
public function interpret($line)
{
$this->checkRowConsistency($line);
if (!is_array($line)) {
throw new InvalidLexicalException('line is must be array');
}
$this->notify($line);
}
|
interpret line
@param $line
@return void
@throws \Goodby\CSV\Import\Protocol\Exception\InvalidLexicalException
|
interpret
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/Interpreter.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/Interpreter.php
|
MIT
|
private function delegate($observer, $line)
{
call_user_func($observer, $line);
}
|
delegate to observer
@param $observer
@param $line
|
delegate
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/Interpreter.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/Interpreter.php
|
MIT
|
private function checkCallable($observer)
{
if (!is_callable($observer)) {
throw new \InvalidArgumentException('observer must be callable');
}
}
|
check observer is callable
@param $observer
@throws \InvalidArgumentException
|
checkCallable
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/Interpreter.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/Interpreter.php
|
MIT
|
public function __construct(LexerConfig $config = null)
{
if (!$config) {
$config = new LexerConfig();
}
$this->config = $config;
ConvertMbstringEncoding::register();
}
|
Return new Lexer object
@param LexerConfig $config
|
__construct
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/Lexer.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/Lexer.php
|
MIT
|
public function setEnclosure($enclosure)
{
$this->enclosure = $enclosure;
return $this;
}
|
Set enclosure
@param string $enclosure
@return LexerConfig
|
setEnclosure
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public function setEscape($escape)
{
$this->escape = $escape;
return $this;
}
|
Set escape
@param string $escape
@return LexerConfig
|
setEscape
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public function setFromCharset($fromCharset)
{
$this->fromCharset = $fromCharset;
return $this;
}
|
Set from-character set
@param string $fromCharset
@return LexerConfig
|
setFromCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public function getFromCharset()
{
return $this->fromCharset;
}
|
Return from-character set
@return string
|
getFromCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public function setToCharset($toCharset)
{
$this->toCharset = $toCharset;
return $this;
}
|
Set to-character set
@param string $toCharset
@return LexerConfig
|
setToCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public function getToCharset()
{
return $this->toCharset;
}
|
Return to-character set
@return string
|
getToCharset
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public function setFlags($flags)
{
$this->flags = $flags;
return $this;
}
|
Set flags
@param integer $flags Bit mask of the flags to set. See SplFileObject constants for the available flags.
@return LexerConfig
@see http://php.net/manual/en/class.splfileobject.php#splfileobject.constants
|
setFlags
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/LexerConfig.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/LexerConfig.php
|
MIT
|
public static function register()
{
if ( self::$hasBeenRegistered === true ) {
return;
}
if ( stream_filter_register(self::getFilterName(), __CLASS__) === false ) {
throw new RuntimeException('Failed to register stream filter: '.self::getFilterName());
}
self::$hasBeenRegistered = true;
}
|
Register this class as a stream filter
@throws \RuntimeException
|
register
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/StreamFilter/ConvertMbstringEncoding.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/StreamFilter/ConvertMbstringEncoding.php
|
MIT
|
public static function getFilterURL($filename, $fromCharset, $toCharset = null)
{
if ( $toCharset === null ) {
return sprintf('php://filter/convert.mbstring.encoding.%s/resource=%s', $fromCharset, $filename);
} else {
return sprintf('php://filter/convert.mbstring.encoding.%s:%s/resource=%s', $fromCharset, $toCharset, $filename);
}
}
|
Return filter URL
@param string $filename
@param string $fromCharset
@param string $toCharset
@return string
|
getFilterURL
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/StreamFilter/ConvertMbstringEncoding.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/StreamFilter/ConvertMbstringEncoding.php
|
MIT
|
public function filter($in, $out, &$consumed, $closing)
{
while ( $bucket = stream_bucket_make_writeable($in) ) {
$bucket->data = mb_convert_encoding($bucket->data, $this->toCharset, $this->fromCharset);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
|
@param string $in
@param string $out
@param string $consumed
@param $closing
@return int
|
filter
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Standard/StreamFilter/ConvertMbstringEncoding.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Standard/StreamFilter/ConvertMbstringEncoding.php
|
MIT
|
public function testInterpreterInterfaceWillThrownInvalidLexicalException()
{
$interpreter = $this->getMock('\Goodby\CSV\Import\Protocol\InterpreterInterface');
$interpreter->expects($this->once())
->method('interpret')
->will($this->throwException(new InvalidLexicalException()))
;
$line = "INVALID LEXICAL";
$interpreter->interpret($line);
}
|
@expectedException \Goodby\CSV\Import\Protocol\Exception\InvalidLexicalException
|
testInterpreterInterfaceWillThrownInvalidLexicalException
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Protocol/InterpreterTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Protocol/InterpreterTest.php
|
MIT
|
public function testCsvFileNotFound()
{
$lexer = m::mock('\Goodby\CSV\Import\Protocol\LexerInterface');
$interpreter = m::mock('\Goodby\CSV\Import\Protocol\InterpreterInterface');
$path = 'invalid_dummy.csv';
$lexer->shouldReceive('parse')
->with($path, $interpreter)
->andThrow('Goodby\CSV\Import\Protocol\Exception\CsvFileNotFoundException')
;
$lexer->parse($path, $interpreter);
}
|
@expectedException \Goodby\CSV\Import\Protocol\Exception\CsvFileNotFoundException
|
testCsvFileNotFound
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Protocol/LexerTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Protocol/LexerTest.php
|
MIT
|
public function testInvalidLine()
{
$interpreter = new Interpreter();
$table = 'test';
$options = array('user' => $this->manager->getUser(), 'password' => $this->manager->getPassword());
$sqlObserver = new PdoObserver($table, array('id', 'name'), $this->manager->getDsn(), $options);
$interpreter->addObserver(array($sqlObserver, 'notify'));
$interpreter->interpret(array('123', array('test', 'test')));
}
|
@expectedException \InvalidArgumentException
@expectedExceptionMessage value is invalid: array
|
testInvalidLine
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Standard/Join/Observer/PdoObserverTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Standard/Join/Observer/PdoObserverTest.php
|
MIT
|
public function testInconsistentColumns()
{
$lines[] = array('test', 'test', 'test');
$lines[] = array('test', 'test');
$interpreter = new Interpreter();
foreach ($lines as $line) {
$interpreter->interpret($line);
}
}
|
@expectedException \Goodby\CSV\Import\Standard\Exception\StrictViolationException
|
testInconsistentColumns
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
MIT
|
public function testInconsistentColumnsLowToHigh()
{
$lines[] = array('test', 'test');
$lines[] = array('test', 'test', 'test');
$interpreter = new Interpreter();
foreach ($lines as $line) {
$interpreter->interpret($line);
}
}
|
@expectedException \Goodby\CSV\Import\Standard\Exception\StrictViolationException
|
testInconsistentColumnsLowToHigh
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
MIT
|
public function testInconsistentColumnsWithUnStrict()
{
$lines[] = array('test', 'test', 'test');
$lines[] = array('test', 'test');
$interpreter = new Interpreter();
$interpreter->unstrict();
foreach ($lines as $line) {
$interpreter->interpret($line);
}
}
|
use un-strict won't throw exception with inconsistent columns
|
testInconsistentColumnsWithUnStrict
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
MIT
|
public function testStandardInterpreterWithInvalidLexical()
{
$this->expectedLine = '';
$interpreter = new Interpreter();
$interpreter->interpret($this->expectedLine);
}
|
@expectedException \Goodby\CSV\Import\Protocol\Exception\InvalidLexicalException
|
testStandardInterpreterWithInvalidLexical
|
php
|
goodby/csv
|
src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
https://github.com/goodby/csv/blob/master/src/Goodby/CSV/Import/Tests/Standard/Unit/InterpreterTest.php
|
MIT
|
public function __construct(SomeClass $someClass, SomeOtherClass $someOtherClass)
{
$this->someClass = $someClass;
$this->someOtherClass = $someOtherClass;
}
|
@param SomeClass $someClass
@param SomeOtherClass $someOtherClass
|
__construct
|
php
|
deptrac/deptrac
|
docs/examples/Layer1/AnotherClassLikeAController.php
|
https://github.com/deptrac/deptrac/blob/master/docs/examples/Layer1/AnotherClassLikeAController.php
|
MIT
|
public function rules() : array
{
return $this->rules;
}
|
@return array<class-string<RuleInterface>, array<int, RuleInterface>>
|
rules
|
php
|
deptrac/deptrac
|
src/Contract/Analyser/AnalysisResult.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Analyser/AnalysisResult.php
|
MIT
|
public function __construct(private readonly array $skippedViolations, public readonly LayerProvider $layerProvider)
{
$this->unmatchedSkippedViolation = $skippedViolations;
}
|
@param array<string, list<string>> $skippedViolations
|
__construct
|
php
|
deptrac/deptrac
|
src/Contract/Analyser/EventHelper.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Analyser/EventHelper.php
|
MIT
|
public function unmatchedSkippedViolations() : array
{
return \array_filter($this->unmatchedSkippedViolation);
}
|
@return array<string, string[]> depender layer -> list<dependent layers>
|
unmatchedSkippedViolations
|
php
|
deptrac/deptrac
|
src/Contract/Analyser/EventHelper.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Analyser/EventHelper.php
|
MIT
|
public function toArray() : array
{
return ['type' => $this->collectorType->value, 'private' => $this->private];
}
|
@return array{'type': string, 'private': bool, ...}
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/CollectorConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/CollectorConfig.php
|
MIT
|
public function toArray() : array
{
return ['value' => $this->config, 'type' => $this->collectorType->value, 'private' => $this->private];
}
|
@return array{private: bool, type: string, value: string}
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/ConfigurableCollectorConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/ConfigurableCollectorConfig.php
|
MIT
|
public function analysers(\Deptrac\Deptrac\Contract\Config\EmitterType ...$types) : self
{
return $this->analyser(\Deptrac\Deptrac\Contract\Config\AnalyserConfig::create($types));
}
|
@deprecated use analyser(AnalyserConfig::create()) instead
|
analysers
|
php
|
deptrac/deptrac
|
src/Contract/Config/DeptracConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/DeptracConfig.php
|
MIT
|
public function toArray() : array
{
$data = \array_map(static fn(\Deptrac\Deptrac\Contract\Config\Layer $layerConfig) => $layerConfig->name, $this->accessableLayers);
return $data + ['name' => $this->layerConfig->name];
}
|
@return non-empty-array<array-key, string>
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/Ruleset.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/Ruleset.php
|
MIT
|
public static function create(array $must = [], array $mostNot = []) : self
{
return (new self())->must(...$must)->mustNot(...$mostNot);
}
|
@param array<CollectorConfig> $must
@param array<CollectorConfig> $mostNot
|
create
|
php
|
deptrac/deptrac
|
src/Contract/Config/Collector/BoolConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/Collector/BoolConfig.php
|
MIT
|
public function toArray() : array
{
return ['must_not' => \array_map(static fn(CollectorConfig $v) => $v->toArray(), $this->mustNot), 'must' => \array_map(static fn(CollectorConfig $v) => $v->toArray(), $this->must), 'private' => $this->private, 'type' => $this->collectorType->value];
}
|
@return array{
must: array<array-key, array{private: bool, type: string}>|mixed,
must_not: array<array-key, array{private: bool, type: string}>|mixed,
private: bool,
type: string}
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/Collector/BoolConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/Collector/BoolConfig.php
|
MIT
|
public function toArray() : array
{
return ['composerPath' => $this->composerPath, 'composerLockPath' => $this->composerLockPath, 'packages' => $this->packages, 'private' => $this->private, 'type' => $this->collectorType->value];
}
|
@return array{
composerPath: string,
composerLockPath: string,
packages: list<string>,
private: bool,
type: string}
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/Collector/ComposerConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/Collector/ComposerConfig.php
|
MIT
|
public function toArray() : array
{
return ['private' => $this->private, 'type' => $this->collectorType->value, 'value' => $this->config];
}
|
@return array{'private': bool, 'type': string, 'value': string[]}
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/Collector/SuperGlobalConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/Collector/SuperGlobalConfig.php
|
MIT
|
public function toArray() : array
{
return ['severity' => ['failure' => $this->failure->value, 'skipped' => $this->skipped->value, 'uncovered' => $this->uncovered->value]];
}
|
@return array{'severity': array{'failure': string, 'skipped': string, 'uncovered': string}}
|
toArray
|
php
|
deptrac/deptrac
|
src/Contract/Config/Formatter/CodeclimateConfig.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Config/Formatter/CodeclimateConfig.php
|
MIT
|
private function getTransitiveDependencies(string $layerName, array $previousLayers) : array
{
if (\in_array($layerName, $previousLayers, \true)) {
throw \Deptrac\Deptrac\Contract\Layer\CircularReferenceException::circularLayerDependency($layerName, $previousLayers);
}
$dependencies = [];
foreach ($this->allowedLayers[$layerName] ?? [] as $layer) {
if (\str_starts_with($layer, '+')) {
$layer = \ltrim($layer, '+');
$dependencies[] = $this->getTransitiveDependencies($layer, \array_merge([$layerName], $previousLayers));
}
$dependencies[] = [$layer];
}
return [] === $dependencies ? [] : \array_merge(...$dependencies);
}
|
@param list<string> $previousLayers
@return string[]
@throws CircularReferenceException
|
getTransitiveDependencies
|
php
|
deptrac/deptrac
|
src/Contract/Layer/LayerProvider.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Layer/LayerProvider.php
|
MIT
|
public function allOf(string $type) : array
{
return \array_key_exists($type, $this->rules) ? \array_values($this->rules[$type]) : [];
}
|
@template T of RuleInterface
@param class-string<T> $type
@return list<T>
|
allOf
|
php
|
deptrac/deptrac
|
src/Contract/Result/OutputResult.php
|
https://github.com/deptrac/deptrac/blob/master/src/Contract/Result/OutputResult.php
|
MIT
|
public function getDependencies(string $layer, ?string $targetLayer) : array
{
try {
$result = [];
$astMap = $this->astMapExtractor->extract();
$dependencies = $this->dependencyResolver->resolve($astMap);
foreach ($dependencies->getDependenciesAndInheritDependencies() as $dependency) {
$dependerLayerNames = $this->layerResolver->getLayersForReference($this->tokenResolver->resolve($dependency->getDepender(), $astMap));
if (\array_key_exists($layer, $dependerLayerNames)) {
$dependentLayerNames = $this->layerResolver->getLayersForReference($this->tokenResolver->resolve($dependency->getDependent(), $astMap));
foreach ($dependentLayerNames as $dependentLayerName => $_) {
if ($layer === $dependentLayerName || null !== $targetLayer && $targetLayer !== $dependentLayerName) {
continue;
}
$result[$dependentLayerName][] = new Uncovered($dependency, $dependentLayerName);
}
}
}
return $result;
} catch (InvalidEmitterConfigurationException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidEmitterConfiguration($e);
} catch (UnrecognizedTokenException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::unrecognizedToken($e);
} catch (InvalidLayerDefinitionException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidLayerDefinition($e);
} catch (InvalidCollectorDefinitionException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidCollectorDefinition($e);
} catch (AstException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::failedAstParsing($e);
} catch (CouldNotParseFileException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::couldNotParseFile($e);
}
}
|
@return array<string, list<Uncovered>>
@throws AnalyserException
|
getDependencies
|
php
|
deptrac/deptrac
|
src/Core/Analyser/LayerDependenciesAnalyser.php
|
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/LayerDependenciesAnalyser.php
|
MIT
|
public function findLayerForToken(string $tokenName, \Deptrac\Deptrac\Core\Analyser\TokenType $tokenType) : array
{
try {
$astMap = $this->astMapExtractor->extract();
return match ($tokenType) {
\Deptrac\Deptrac\Core\Analyser\TokenType::CLASS_LIKE => $this->findLayersForReferences($astMap->getClassLikeReferences(), $tokenName, $astMap),
\Deptrac\Deptrac\Core\Analyser\TokenType::FUNCTION => $this->findLayersForReferences($astMap->getFunctionReferences(), $tokenName, $astMap),
\Deptrac\Deptrac\Core\Analyser\TokenType::FILE => $this->findLayersForReferences($astMap->getFileReferences(), $tokenName, $astMap),
};
} catch (UnrecognizedTokenException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::unrecognizedToken($e);
} catch (InvalidLayerDefinitionException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidLayerDefinition($e);
} catch (InvalidCollectorDefinitionException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidCollectorDefinition($e);
} catch (AstException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::failedAstParsing($e);
} catch (CouldNotParseFileException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::couldNotParseFile($e);
}
}
|
@return array<string, string[]>
@throws AnalyserException
|
findLayerForToken
|
php
|
deptrac/deptrac
|
src/Core/Analyser/LayerForTokenAnalyser.php
|
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/LayerForTokenAnalyser.php
|
MIT
|
private function findLayersForReferences(array $references, string $tokenName, AstMap $astMap) : array
{
if ([] === $references) {
return [];
}
$layersForReference = [];
foreach ($references as $reference) {
if (!str_contains($reference->getToken()->toString(), $tokenName)) {
continue;
}
$token = $this->tokenResolver->resolve($reference->getToken(), $astMap);
$matchingLayers = \array_keys($this->layerResolver->getLayersForReference($token));
natcasesort($matchingLayers);
$layersForReference[$reference->getToken()->toString()] = array_values($matchingLayers);
}
ksort($layersForReference);
return $layersForReference;
}
|
@param TokenReferenceInterface[] $references
@return array<string, string[]>
@throws UnrecognizedTokenException
@throws InvalidLayerDefinitionException
@throws InvalidCollectorDefinitionException
@throws CouldNotParseFileException
|
findLayersForReferences
|
php
|
deptrac/deptrac
|
src/Core/Analyser/LayerForTokenAnalyser.php
|
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/LayerForTokenAnalyser.php
|
MIT
|
public function analyse() : array
{
try {
return $this->findRulesetUsages($this->rulesetResolution());
} catch (InvalidEmitterConfigurationException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidEmitterConfiguration($e);
} catch (UnrecognizedTokenException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::unrecognizedToken($e);
} catch (InvalidLayerDefinitionException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidLayerDefinition($e);
} catch (InvalidCollectorDefinitionException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::invalidCollectorDefinition($e);
} catch (AstException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::failedAstParsing($e);
} catch (CouldNotParseFileException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::couldNotParseFile($e);
} catch (CircularReferenceException $e) {
throw \Deptrac\Deptrac\Core\Analyser\AnalyserException::circularReference($e);
}
}
|
@return array<string, array<string, int>>
@throws AnalyserException
|
analyse
|
php
|
deptrac/deptrac
|
src/Core/Analyser/RulesetUsageAnalyser.php
|
https://github.com/deptrac/deptrac/blob/master/src/Core/Analyser/RulesetUsageAnalyser.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.