repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINean13.php | CINean13.draw | public function draw($im) {
$this->drawBars($im);
$this->drawText($im, 0, 0, $this->positionX, $this->thickness);
if ($this->isDefaultEanLabelEnabled()) {
$dimension = $this->labelCenter1->getDimension();
$this->drawExtendedBars($im, $dimension[1] - 2);
}
... | php | public function draw($im) {
$this->drawBars($im);
$this->drawText($im, 0, 0, $this->positionX, $this->thickness);
if ($this->isDefaultEanLabelEnabled()) {
$dimension = $this->labelCenter1->getDimension();
$this->drawExtendedBars($im, $dimension[1] - 2);
}
... | [
"public",
"function",
"draw",
"(",
"$",
"im",
")",
"{",
"$",
"this",
"->",
"drawBars",
"(",
"$",
"im",
")",
";",
"$",
"this",
"->",
"drawText",
"(",
"$",
"im",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"positionX",
",",
"$",
"this",
"->",
"... | Draws the barcode.
@param resource $im | [
"Draws",
"the",
"barcode",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINean13.php#L83-L91 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINean13.php | CINean13.addDefaultLabel | protected function addDefaultLabel() {
if ($this->isDefaultEanLabelEnabled()) {
$this->processChecksum();
$label = $this->getLabel();
$font = $this->font;
$this->labelLeft = new CINLabel(substr($label, 0, 1), $font, CINLabel::POSITION_LEFT, CINLabel::ALIGN_... | php | protected function addDefaultLabel() {
if ($this->isDefaultEanLabelEnabled()) {
$this->processChecksum();
$label = $this->getLabel();
$font = $this->font;
$this->labelLeft = new CINLabel(substr($label, 0, 1), $font, CINLabel::POSITION_LEFT, CINLabel::ALIGN_... | [
"protected",
"function",
"addDefaultLabel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDefaultEanLabelEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"processChecksum",
"(",
")",
";",
"$",
"label",
"=",
"$",
"this",
"->",
"getLabel",
"(",
")",
";... | Adds the default label. | [
"Adds",
"the",
"default",
"label",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINean13.php#L114-L142 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINean13.php | CINean13.validate | protected function validate() {
$c = strlen($this->text);
if ($c === 0) {
throw new CINParseException('ean13', 'No data has been entered.');
}
$this->checkCharsAllowed();
$this->checkCorrectLength();
parent::validate();
} | php | protected function validate() {
$c = strlen($this->text);
if ($c === 0) {
throw new CINParseException('ean13', 'No data has been entered.');
}
$this->checkCharsAllowed();
$this->checkCorrectLength();
parent::validate();
} | [
"protected",
"function",
"validate",
"(",
")",
"{",
"$",
"c",
"=",
"strlen",
"(",
"$",
"this",
"->",
"text",
")",
";",
"if",
"(",
"$",
"c",
"===",
"0",
")",
"{",
"throw",
"new",
"CINParseException",
"(",
"'ean13'",
",",
"'No data has been entered.'",
"... | Validates the input. | [
"Validates",
"the",
"input",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINean13.php#L158-L168 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINean13.php | CINean13.checkCorrectLength | protected function checkCorrectLength() {
// If we have 13 chars, just flush the last one without throwing anything
$c = strlen($this->text);
if ($c === 13) {
$this->text = substr($this->text, 0, 12);
} elseif ($c !== 12) {
throw new CINParseException('ean13... | php | protected function checkCorrectLength() {
// If we have 13 chars, just flush the last one without throwing anything
$c = strlen($this->text);
if ($c === 13) {
$this->text = substr($this->text, 0, 12);
} elseif ($c !== 12) {
throw new CINParseException('ean13... | [
"protected",
"function",
"checkCorrectLength",
"(",
")",
"{",
"// If we have 13 chars, just flush the last one without throwing anything\r",
"$",
"c",
"=",
"strlen",
"(",
"$",
"this",
"->",
"text",
")",
";",
"if",
"(",
"$",
"c",
"===",
"13",
")",
"{",
"$",
"this... | Check correct length. | [
"Check",
"correct",
"length",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINean13.php#L186-L194 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINean13.php | CINean13.drawBars | protected function drawBars($im) {
// Checksum
$this->calculateChecksum();
$temp_text = $this->text . $this->keys[$this->checksumValue];
// Starting Code
$this->drawChar($im, '000', true);
// Draw Second Code
$this->drawChar($im, $this->findCode($temp_t... | php | protected function drawBars($im) {
// Checksum
$this->calculateChecksum();
$temp_text = $this->text . $this->keys[$this->checksumValue];
// Starting Code
$this->drawChar($im, '000', true);
// Draw Second Code
$this->drawChar($im, $this->findCode($temp_t... | [
"protected",
"function",
"drawBars",
"(",
"$",
"im",
")",
"{",
"// Checksum\r",
"$",
"this",
"->",
"calculateChecksum",
"(",
")",
";",
"$",
"temp_text",
"=",
"$",
"this",
"->",
"text",
".",
"$",
"this",
"->",
"keys",
"[",
"$",
"this",
"->",
"checksumVa... | Draws the bars
@param resource $im | [
"Draws",
"the",
"bars"
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINean13.php#L248-L274 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINcode11.php | CINcode11.draw | public function draw($im) {
// Starting Code
$this->drawChar($im, '001100', true);
// Chars
$c = strlen($this->text);
for ($i = 0; $i < $c; $i++) {
$this->drawChar($im, $this->findCode($this->text[$i]), true);
}
// Checksum
$this->... | php | public function draw($im) {
// Starting Code
$this->drawChar($im, '001100', true);
// Chars
$c = strlen($this->text);
for ($i = 0; $i < $c; $i++) {
$this->drawChar($im, $this->findCode($this->text[$i]), true);
}
// Checksum
$this->... | [
"public",
"function",
"draw",
"(",
"$",
"im",
")",
"{",
"// Starting Code\r",
"$",
"this",
"->",
"drawChar",
"(",
"$",
"im",
",",
"'001100'",
",",
"true",
")",
";",
"// Chars\r",
"$",
"c",
"=",
"strlen",
"(",
"$",
"this",
"->",
"text",
")",
";",
"f... | Draws the barcode.
@param resource $im | [
"Draws",
"the",
"barcode",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINcode11.php#L44-L64 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINcode11.php | CINcode11.getDimension | public function getDimension($w, $h) {
$startlength = 8;
$textlength = 0;
$c = strlen($this->text);
for ($i = 0; $i < $c; $i++) {
$textlength += $this->getIndexLength($this->findIndex($this->text[$i]));
}
$checksumlength = 0;
$this->calcula... | php | public function getDimension($w, $h) {
$startlength = 8;
$textlength = 0;
$c = strlen($this->text);
for ($i = 0; $i < $c; $i++) {
$textlength += $this->getIndexLength($this->findIndex($this->text[$i]));
}
$checksumlength = 0;
$this->calcula... | [
"public",
"function",
"getDimension",
"(",
"$",
"w",
",",
"$",
"h",
")",
"{",
"$",
"startlength",
"=",
"8",
";",
"$",
"textlength",
"=",
"0",
";",
"$",
"c",
"=",
"strlen",
"(",
"$",
"this",
"->",
"text",
")",
";",
"for",
"(",
"$",
"i",
"=",
"... | Returns the maximal size of a barcode.
@param int $w
@param int $h
@return int[] | [
"Returns",
"the",
"maximal",
"size",
"of",
"a",
"barcode",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINcode11.php#L73-L95 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINcode11.php | CINcode11.calculateChecksum | protected function calculateChecksum() {
// Checksum
// First CheckSUM "C"
// The "C" checksum character is the modulo 11 remainder of the sum of the weighted
// value of the data characters. The weighting value starts at "1" for the right-most
// data character, 2 for the s... | php | protected function calculateChecksum() {
// Checksum
// First CheckSUM "C"
// The "C" checksum character is the modulo 11 remainder of the sum of the weighted
// value of the data characters. The weighting value starts at "1" for the right-most
// data character, 2 for the s... | [
"protected",
"function",
"calculateChecksum",
"(",
")",
"{",
"// Checksum\r",
"// First CheckSUM \"C\"\r",
"// The \"C\" checksum character is the modulo 11 remainder of the sum of the weighted\r",
"// value of the data characters. The weighting value starts at \"1\" for the right-most\r",
"// d... | Overloaded method to calculate checksum. | [
"Overloaded",
"method",
"to",
"calculate",
"checksum",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINcode11.php#L119-L154 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINmsi.php | CINmsi.setChecksum | public function setChecksum($checksum) {
$checksum = intval($checksum);
if ($checksum < 0 && $checksum > 2) {
throw new CINArgumentException('The checksum must be between 0 and 2 included.', 'checksum');
}
$this->checksum = $checksum;
} | php | public function setChecksum($checksum) {
$checksum = intval($checksum);
if ($checksum < 0 && $checksum > 2) {
throw new CINArgumentException('The checksum must be between 0 and 2 included.', 'checksum');
}
$this->checksum = $checksum;
} | [
"public",
"function",
"setChecksum",
"(",
"$",
"checksum",
")",
"{",
"$",
"checksum",
"=",
"intval",
"(",
"$",
"checksum",
")",
";",
"if",
"(",
"$",
"checksum",
"<",
"0",
"&&",
"$",
"checksum",
">",
"2",
")",
"{",
"throw",
"new",
"CINArgumentException"... | Sets how many checksums we display. 0 to 2.
@param int $checksum | [
"Sets",
"how",
"many",
"checksums",
"we",
"display",
".",
"0",
"to",
"2",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINmsi.php#L48-L55 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINmsi.php | CINmsi.calculateChecksum | protected function calculateChecksum() {
// Forming a new number
// If the original number is even, we take all even position
// If the original number is odd, we take all odd position
// 123456 = 246
// 12345 = 135
// Multiply by 2
// Add up all the digit ... | php | protected function calculateChecksum() {
// Forming a new number
// If the original number is even, we take all even position
// If the original number is odd, we take all odd position
// 123456 = 246
// 12345 = 135
// Multiply by 2
// Add up all the digit ... | [
"protected",
"function",
"calculateChecksum",
"(",
")",
"{",
"// Forming a new number\r",
"// If the original number is even, we take all even position\r",
"// If the original number is odd, we take all odd position\r",
"// 123456 = 246\r",
"// 12345 = 135\r",
"// Multiply by 2\r",
"// Add u... | Overloaded method to calculate checksum. | [
"Overloaded",
"method",
"to",
"calculate",
"checksum",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINmsi.php#L123-L163 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.parse | public function parse($text) {
$parsedText = $this->parseGs1128($text);
if($this->customLabelText!==false and CINBarcode1D::AUTO_LABEL!=$this->customLabelText){
parent::setLabel($this->customLabelText);
}
parent::parse($parsedText);
} | php | public function parse($text) {
$parsedText = $this->parseGs1128($text);
if($this->customLabelText!==false and CINBarcode1D::AUTO_LABEL!=$this->customLabelText){
parent::setLabel($this->customLabelText);
}
parent::parse($parsedText);
} | [
"public",
"function",
"parse",
"(",
"$",
"text",
")",
"{",
"$",
"parsedText",
"=",
"$",
"this",
"->",
"parseGs1128",
"(",
"$",
"text",
")",
";",
"if",
"(",
"$",
"this",
"->",
"customLabelText",
"!==",
"false",
"and",
"CINBarcode1D",
"::",
"AUTO_LABEL",
... | Parses Text.
@param string $text | [
"Parses",
"Text",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L249-L255 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.formatGs1128 | private function formatGs1128() {
$formatedText = '~F1';
$formatedLabel = '';
$c = count($this->identifiersId);
for ($i = 0; $i < $c; $i++) {
if ($i > 0) {
$formatedLabel .= ' ';
}
if ($this->identifiersId[$i] !== null) {
... | php | private function formatGs1128() {
$formatedText = '~F1';
$formatedLabel = '';
$c = count($this->identifiersId);
for ($i = 0; $i < $c; $i++) {
if ($i > 0) {
$formatedLabel .= ' ';
}
if ($this->identifiersId[$i] !== null) {
... | [
"private",
"function",
"formatGs1128",
"(",
")",
"{",
"$",
"formatedText",
"=",
"'~F1'",
";",
"$",
"formatedLabel",
"=",
"''",
";",
"$",
"c",
"=",
"count",
"(",
"$",
"this",
"->",
"identifiersId",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",... | Formats data for gs1-128.
@return string | [
"Formats",
"data",
"for",
"gs1",
"-",
"128",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L262-L308 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.parseGs1128 | private function parseGs1128($text) {
/* We format correctly what the user gives */
if (is_array($text)) {
$formatArray = array();
foreach ($text as $content) {
if (is_array($content)) { /* double array */
if (count($content) === 2) {
... | php | private function parseGs1128($text) {
/* We format correctly what the user gives */
if (is_array($text)) {
$formatArray = array();
foreach ($text as $content) {
if (is_array($content)) { /* double array */
if (count($content) === 2) {
... | [
"private",
"function",
"parseGs1128",
"(",
"$",
"text",
")",
"{",
"/* We format correctly what the user gives */",
"if",
"(",
"is_array",
"(",
"$",
"text",
")",
")",
"{",
"$",
"formatArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"text",
"as",
"... | Parses the text to gs1-128.
@param mixed $text
@return mixed | [
"Parses",
"the",
"text",
"to",
"gs1",
"-",
"128",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L316-L351 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.parseContent | private function parseContent($text) {
/* $yAlreadySet has 3 states: */
/* null: There is no variable in the ID; true: the variable is already set; false: the variable is not set yet; */
$content = null;
$yAlreadySet = null;
$realNameId = null;
$separatorsFound = 0;... | php | private function parseContent($text) {
/* $yAlreadySet has 3 states: */
/* null: There is no variable in the ID; true: the variable is already set; false: the variable is not set yet; */
$content = null;
$yAlreadySet = null;
$realNameId = null;
$separatorsFound = 0;... | [
"private",
"function",
"parseContent",
"(",
"$",
"text",
")",
"{",
"/* $yAlreadySet has 3 states: */",
"/* null: There is no variable in the ID; true: the variable is already set; false: the variable is not set yet; */",
"$",
"content",
"=",
"null",
";",
"$",
"yAlreadySet",
"=",
... | Splits the id and the content for each application identifiers (AIs).
@param string $text
@param int $cmpt
@return bool | [
"Splits",
"the",
"id",
"and",
"the",
"content",
"for",
"each",
"application",
"identifiers",
"(",
"AIs",
")",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L360-L450 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.idExists | private function idExists($id, &$yAlreadySet, &$realNameId) {
$yFound = isset($id[3]) && $id[3] === 'y';
$idVarAdded = substr($id, 0, -1) . 'y';
if (isset($this->identifiersAi[$id])) {
if ($yFound) {
$yAlreadySet = false;
}
$realName... | php | private function idExists($id, &$yAlreadySet, &$realNameId) {
$yFound = isset($id[3]) && $id[3] === 'y';
$idVarAdded = substr($id, 0, -1) . 'y';
if (isset($this->identifiersAi[$id])) {
if ($yFound) {
$yAlreadySet = false;
}
$realName... | [
"private",
"function",
"idExists",
"(",
"$",
"id",
",",
"&",
"$",
"yAlreadySet",
",",
"&",
"$",
"realNameId",
")",
"{",
"$",
"yFound",
"=",
"isset",
"(",
"$",
"id",
"[",
"3",
"]",
")",
"&&",
"$",
"id",
"[",
"3",
"]",
"===",
"'y'",
";",
"$",
"... | Checks if an id exists.
@param string $id
@param bool $yAlreadySet
@param string $realNameId
@return bool | [
"Checks",
"if",
"an",
"id",
"exists",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L460-L479 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.findIdFormated | private function findIdFormated($id, &$yAlreadySet, &$realNameId) {
$pos = strpos($id, ')');
if ($pos === false) {
throw new CINParseException('gs1128', 'Identifiers must have no more than 4 characters.');
} else {
if ($pos < 3) {
throw new CINParseE... | php | private function findIdFormated($id, &$yAlreadySet, &$realNameId) {
$pos = strpos($id, ')');
if ($pos === false) {
throw new CINParseException('gs1128', 'Identifiers must have no more than 4 characters.');
} else {
if ($pos < 3) {
throw new CINParseE... | [
"private",
"function",
"findIdFormated",
"(",
"$",
"id",
",",
"&",
"$",
"yAlreadySet",
",",
"&",
"$",
"realNameId",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"id",
",",
"')'",
")",
";",
"if",
"(",
"$",
"pos",
"===",
"false",
")",
"{",
"throw... | Finds ID with formated content.
@param string $id
@param bool $yAlreadySet
@param string $realNameId
@return mixed | [
"Finds",
"ID",
"with",
"formated",
"content",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L489-L509 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.findIdNotFormated | private function findIdNotFormated($id, &$yAlreadySet, &$realNameId) {
$tofind = $id;
while (strlen($tofind) >= 2) {
if ($this->idExists($tofind, $yAlreadySet, $realNameId)) {
return $tofind;
} else {
$tofind = substr($tofind, 0, -1);
... | php | private function findIdNotFormated($id, &$yAlreadySet, &$realNameId) {
$tofind = $id;
while (strlen($tofind) >= 2) {
if ($this->idExists($tofind, $yAlreadySet, $realNameId)) {
return $tofind;
} else {
$tofind = substr($tofind, 0, -1);
... | [
"private",
"function",
"findIdNotFormated",
"(",
"$",
"id",
",",
"&",
"$",
"yAlreadySet",
",",
"&",
"$",
"realNameId",
")",
"{",
"$",
"tofind",
"=",
"$",
"id",
";",
"while",
"(",
"strlen",
"(",
"$",
"tofind",
")",
">=",
"2",
")",
"{",
"if",
"(",
... | Finds ID with non-formated content.
@param string $id
@param bool $yAlreadySet
@param string $realNameId
@return mixed | [
"Finds",
"ID",
"with",
"non",
"-",
"formated",
"content",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L519-L535 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.checkConformity | private function checkConformity(&$content, $id, $realNameId) {
switch ($this->identifiersAi[$realNameId][self::KIND_OF_DATA]) {
case self::NUMERIC:
$content = str_replace(',', '.', $content);
if (!preg_match("/^[0-9.]+$/", $content)) {
throw ... | php | private function checkConformity(&$content, $id, $realNameId) {
switch ($this->identifiersAi[$realNameId][self::KIND_OF_DATA]) {
case self::NUMERIC:
$content = str_replace(',', '.', $content);
if (!preg_match("/^[0-9.]+$/", $content)) {
throw ... | [
"private",
"function",
"checkConformity",
"(",
"&",
"$",
"content",
",",
"$",
"id",
",",
"$",
"realNameId",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"identifiersAi",
"[",
"$",
"realNameId",
"]",
"[",
"self",
"::",
"KIND_OF_DATA",
"]",
")",
"{",
"cas... | Checks confirmity of the content.
@param string $content
@param string $id
@param string $realNameId
@return bool | [
"Checks",
"confirmity",
"of",
"the",
"content",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L545-L595 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.checkChecksum | private function checkChecksum(&$content, $id, $realNameId, &$checksumAdded) {
if ($this->identifiersAi[$realNameId][self::CHECKSUM]) {
$nbCharContent = strlen($content);
$minlengthContent = $this->identifiersAi[$realNameId][self::MINLENGTH];
if ($nbCharContent === ($minl... | php | private function checkChecksum(&$content, $id, $realNameId, &$checksumAdded) {
if ($this->identifiersAi[$realNameId][self::CHECKSUM]) {
$nbCharContent = strlen($content);
$minlengthContent = $this->identifiersAi[$realNameId][self::MINLENGTH];
if ($nbCharContent === ($minl... | [
"private",
"function",
"checkChecksum",
"(",
"&",
"$",
"content",
",",
"$",
"id",
",",
"$",
"realNameId",
",",
"&",
"$",
"checksumAdded",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"identifiersAi",
"[",
"$",
"realNameId",
"]",
"[",
"self",
"::",
"CHECKSUM... | Verifies the checksum.
@param string $content
@param string $id
@param int $realNameId
@param int $checksumAdded
@return bool | [
"Verifies",
"the",
"checksum",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L606-L624 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.checkVars | private function checkVars(&$content, &$id, $yAlreadySet, &$decimalPointRemoved) {
$nbCharContent = strlen($content);
/* We check for "y" var in AI */
if ($yAlreadySet) {
/* We'll check if we have a decimal point */
if (strpos($content, '.') !== false) {
... | php | private function checkVars(&$content, &$id, $yAlreadySet, &$decimalPointRemoved) {
$nbCharContent = strlen($content);
/* We check for "y" var in AI */
if ($yAlreadySet) {
/* We'll check if we have a decimal point */
if (strpos($content, '.') !== false) {
... | [
"private",
"function",
"checkVars",
"(",
"&",
"$",
"content",
",",
"&",
"$",
"id",
",",
"$",
"yAlreadySet",
",",
"&",
"$",
"decimalPointRemoved",
")",
"{",
"$",
"nbCharContent",
"=",
"strlen",
"(",
"$",
"content",
")",
";",
"/* We check for \"y\" var in AI *... | Checks vars "y".
@param string $content
@param string $id
@param bool $yAlreadySet
@param int $decimalPointRemoved
@return bool | [
"Checks",
"vars",
"y",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L635-L656 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINgs1128.php | CINgs1128.calculateChecksumMod10 | private static function calculateChecksumMod10($content) {
// Calculating Checksum
// Consider the right-most digit of the message to be in an "odd" position,
// and assign odd/even to each character moving from right to left
// Odd Position = 3, Even Position = 1
// Multipl... | php | private static function calculateChecksumMod10($content) {
// Calculating Checksum
// Consider the right-most digit of the message to be in an "odd" position,
// and assign odd/even to each character moving from right to left
// Odd Position = 3, Even Position = 1
// Multipl... | [
"private",
"static",
"function",
"calculateChecksumMod10",
"(",
"$",
"content",
")",
"{",
"// Calculating Checksum\r",
"// Consider the right-most digit of the message to be in an \"odd\" position,\r",
"// and assign odd/even to each character moving from right to left\r",
"// Odd Position =... | Checksum Mod10.
@param int $content
@return int | [
"Checksum",
"Mod10",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINgs1128.php#L664-L688 |
codeitnowin/barcode-generator | CodeItNow/BarcodeBundle/Generator/CINs25.php | CINs25.draw | public function draw($im) {
$temp_text = $this->text;
// Checksum
if ($this->checksum === true) {
$this->calculateChecksum();
$temp_text .= $this->keys[$this->checksumValue];
}
// Starting Code
$this->drawChar($im, '101000', true);
... | php | public function draw($im) {
$temp_text = $this->text;
// Checksum
if ($this->checksum === true) {
$this->calculateChecksum();
$temp_text .= $this->keys[$this->checksumValue];
}
// Starting Code
$this->drawChar($im, '101000', true);
... | [
"public",
"function",
"draw",
"(",
"$",
"im",
")",
"{",
"$",
"temp_text",
"=",
"$",
"this",
"->",
"text",
";",
"// Checksum\r",
"if",
"(",
"$",
"this",
"->",
"checksum",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"calculateChecksum",
"(",
")",
";",
... | Draws the barcode.
@param resource $im | [
"Draws",
"the",
"barcode",
"."
] | train | https://github.com/codeitnowin/barcode-generator/blob/6325a15ae904ec401b947e1a3e868de1c2cc80b0/CodeItNow/BarcodeBundle/Generator/CINs25.php#L58-L79 |
adhocore/php-jwt | src/ValidatesJWT.php | ValidatesJWT.validateConfig | protected function validateConfig($key, $algo, $maxAge, $leeway)
{
if (empty($key)) {
throw new JWTException('Signing key cannot be empty', static::ERROR_KEY_EMPTY);
}
if (!isset($this->algos[$algo])) {
throw new JWTException('Unsupported algo ' . $algo, static::ERRO... | php | protected function validateConfig($key, $algo, $maxAge, $leeway)
{
if (empty($key)) {
throw new JWTException('Signing key cannot be empty', static::ERROR_KEY_EMPTY);
}
if (!isset($this->algos[$algo])) {
throw new JWTException('Unsupported algo ' . $algo, static::ERRO... | [
"protected",
"function",
"validateConfig",
"(",
"$",
"key",
",",
"$",
"algo",
",",
"$",
"maxAge",
",",
"$",
"leeway",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"JWTException",
"(",
"'Signing key cannot be empty'",
",",... | Throw up if input parameters invalid.
@codeCoverageIgnore | [
"Throw",
"up",
"if",
"input",
"parameters",
"invalid",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/ValidatesJWT.php#L29-L46 |
adhocore/php-jwt | src/ValidatesJWT.php | ValidatesJWT.validateHeader | protected function validateHeader(array $header)
{
if (empty($header['alg'])) {
throw new JWTException('Invalid token: Missing header algo', static::ERROR_ALGO_MISSING);
}
if (empty($this->algos[$header['alg']])) {
throw new JWTException('Invalid token: Unsupported he... | php | protected function validateHeader(array $header)
{
if (empty($header['alg'])) {
throw new JWTException('Invalid token: Missing header algo', static::ERROR_ALGO_MISSING);
}
if (empty($this->algos[$header['alg']])) {
throw new JWTException('Invalid token: Unsupported he... | [
"protected",
"function",
"validateHeader",
"(",
"array",
"$",
"header",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"header",
"[",
"'alg'",
"]",
")",
")",
"{",
"throw",
"new",
"JWTException",
"(",
"'Invalid token: Missing header algo'",
",",
"static",
"::",
"ERR... | Throw up if header invalid. | [
"Throw",
"up",
"if",
"header",
"invalid",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/ValidatesJWT.php#L51-L61 |
adhocore/php-jwt | src/ValidatesJWT.php | ValidatesJWT.validateKid | protected function validateKid(array $header)
{
if (!isset($header['kid'])) {
return;
}
if (empty($this->keys[$header['kid']])) {
throw new JWTException('Invalid token: Unknown key ID', static::ERROR_KID_UNKNOWN);
}
$this->key = $this->keys[$header['k... | php | protected function validateKid(array $header)
{
if (!isset($header['kid'])) {
return;
}
if (empty($this->keys[$header['kid']])) {
throw new JWTException('Invalid token: Unknown key ID', static::ERROR_KID_UNKNOWN);
}
$this->key = $this->keys[$header['k... | [
"protected",
"function",
"validateKid",
"(",
"array",
"$",
"header",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"header",
"[",
"'kid'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"keys",
"[",
"$",
"heade... | Throw up if kid exists and invalid. | [
"Throw",
"up",
"if",
"kid",
"exists",
"and",
"invalid",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/ValidatesJWT.php#L66-L76 |
adhocore/php-jwt | src/ValidatesJWT.php | ValidatesJWT.validateTimestamps | protected function validateTimestamps(array $payload)
{
$timestamp = $this->timestamp ?: \time();
$checks = [
['exp', $this->leeway /* */ , static::ERROR_TOKEN_EXPIRED, 'Expired'],
['iat', $this->maxAge - $this->leeway, static::ERROR_TOKEN_EXPIRED, 'Expired'],
... | php | protected function validateTimestamps(array $payload)
{
$timestamp = $this->timestamp ?: \time();
$checks = [
['exp', $this->leeway /* */ , static::ERROR_TOKEN_EXPIRED, 'Expired'],
['iat', $this->maxAge - $this->leeway, static::ERROR_TOKEN_EXPIRED, 'Expired'],
... | [
"protected",
"function",
"validateTimestamps",
"(",
"array",
"$",
"payload",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"timestamp",
"?",
":",
"\\",
"time",
"(",
")",
";",
"$",
"checks",
"=",
"[",
"[",
"'exp'",
",",
"$",
"this",
"->",
"leewa... | Throw up if timestamp claims like iat, exp, nbf are invalid. | [
"Throw",
"up",
"if",
"timestamp",
"claims",
"like",
"iat",
"exp",
"nbf",
"are",
"invalid",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/ValidatesJWT.php#L81-L100 |
adhocore/php-jwt | src/ValidatesJWT.php | ValidatesJWT.validateKey | protected function validateKey()
{
if (\is_string($key = $this->key)) {
if (\substr($key, 0, 7) !== 'file://') {
$key = 'file://' . $key;
}
$this->key = \openssl_get_privatekey($key, $this->passphrase ?: '');
}
if (!\is_resource($this->ke... | php | protected function validateKey()
{
if (\is_string($key = $this->key)) {
if (\substr($key, 0, 7) !== 'file://') {
$key = 'file://' . $key;
}
$this->key = \openssl_get_privatekey($key, $this->passphrase ?: '');
}
if (!\is_resource($this->ke... | [
"protected",
"function",
"validateKey",
"(",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"key",
"=",
"$",
"this",
"->",
"key",
")",
")",
"{",
"if",
"(",
"\\",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"7",
")",
"!==",
"'file://'",
")",
"{... | Throw up if key is not resource or file path to private key. | [
"Throw",
"up",
"if",
"key",
"is",
"not",
"resource",
"or",
"file",
"path",
"to",
"private",
"key",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/ValidatesJWT.php#L105-L118 |
adhocore/php-jwt | src/JWT.php | JWT.encode | public function encode(array $payload, array $header = [])
{
$header = ['typ' => 'JWT', 'alg' => $this->algo] + $header;
$this->validateKid($header);
if (!isset($payload['iat']) && !isset($payload['exp'])) {
$payload['exp'] = ($this->timestamp ?: \time()) + $this->maxAge;
... | php | public function encode(array $payload, array $header = [])
{
$header = ['typ' => 'JWT', 'alg' => $this->algo] + $header;
$this->validateKid($header);
if (!isset($payload['iat']) && !isset($payload['exp'])) {
$payload['exp'] = ($this->timestamp ?: \time()) + $this->maxAge;
... | [
"public",
"function",
"encode",
"(",
"array",
"$",
"payload",
",",
"array",
"$",
"header",
"=",
"[",
"]",
")",
"{",
"$",
"header",
"=",
"[",
"'typ'",
"=>",
"'JWT'",
",",
"'alg'",
"=>",
"$",
"this",
"->",
"algo",
"]",
"+",
"$",
"header",
";",
"$",... | Encode payload as JWT token.
@param array $payload
@param array $header Extra header (if any) to append.
@return string URL safe JWT token. | [
"Encode",
"payload",
"as",
"JWT",
"token",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/JWT.php#L118-L133 |
adhocore/php-jwt | src/JWT.php | JWT.decode | public function decode($token)
{
if (\substr_count($token, '.') < 2) {
throw new JWTException('Invalid token: Incomplete segments', static::ERROR_TOKEN_INVALID);
}
$token = \explode('.', $token, 3);
$this->validateHeader((array) $this->urlSafeDecode($token[0]));
... | php | public function decode($token)
{
if (\substr_count($token, '.') < 2) {
throw new JWTException('Invalid token: Incomplete segments', static::ERROR_TOKEN_INVALID);
}
$token = \explode('.', $token, 3);
$this->validateHeader((array) $this->urlSafeDecode($token[0]));
... | [
"public",
"function",
"decode",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"\\",
"substr_count",
"(",
"$",
"token",
",",
"'.'",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"JWTException",
"(",
"'Invalid token: Incomplete segments'",
",",
"static",
"::",
"ERROR_T... | Decode JWT token and return original payload.
@param string $token
@return array | [
"Decode",
"JWT",
"token",
"and",
"return",
"original",
"payload",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/JWT.php#L142-L161 |
adhocore/php-jwt | src/JWT.php | JWT.sign | protected function sign($input)
{
// HMAC SHA.
if (\substr($this->algo, 0, 2) === 'HS') {
return \hash_hmac($this->algos[$this->algo], $input, $this->key, true);
}
$this->validateKey();
\openssl_sign($input, $signature, $this->key, $this->algos[$this->algo]);
... | php | protected function sign($input)
{
// HMAC SHA.
if (\substr($this->algo, 0, 2) === 'HS') {
return \hash_hmac($this->algos[$this->algo], $input, $this->key, true);
}
$this->validateKey();
\openssl_sign($input, $signature, $this->key, $this->algos[$this->algo]);
... | [
"protected",
"function",
"sign",
"(",
"$",
"input",
")",
"{",
"// HMAC SHA.",
"if",
"(",
"\\",
"substr",
"(",
"$",
"this",
"->",
"algo",
",",
"0",
",",
"2",
")",
"===",
"'HS'",
")",
"{",
"return",
"\\",
"hash_hmac",
"(",
"$",
"this",
"->",
"algos",... | Sign the input with configured key and return the signature.
@param string $input
@return string | [
"Sign",
"the",
"input",
"with",
"configured",
"key",
"and",
"return",
"the",
"signature",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/JWT.php#L182-L194 |
adhocore/php-jwt | src/JWT.php | JWT.verify | protected function verify($input, $signature)
{
$algo = $this->algos[$this->algo];
// HMAC SHA.
if (\substr($this->algo, 0, 2) === 'HS') {
return \hash_equals($this->urlSafeEncode(\hash_hmac($algo, $input, $this->key, true)), $signature);
}
$this->validateKey();... | php | protected function verify($input, $signature)
{
$algo = $this->algos[$this->algo];
// HMAC SHA.
if (\substr($this->algo, 0, 2) === 'HS') {
return \hash_equals($this->urlSafeEncode(\hash_hmac($algo, $input, $this->key, true)), $signature);
}
$this->validateKey();... | [
"protected",
"function",
"verify",
"(",
"$",
"input",
",",
"$",
"signature",
")",
"{",
"$",
"algo",
"=",
"$",
"this",
"->",
"algos",
"[",
"$",
"this",
"->",
"algo",
"]",
";",
"// HMAC SHA.",
"if",
"(",
"\\",
"substr",
"(",
"$",
"this",
"->",
"algo"... | Verify the signature of given input.
@param string $input
@param string $signature
@throws JWTException When key is invalid.
@return bool | [
"Verify",
"the",
"signature",
"of",
"given",
"input",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/JWT.php#L206-L220 |
adhocore/php-jwt | src/JWT.php | JWT.urlSafeEncode | protected function urlSafeEncode($data)
{
if (\is_array($data)) {
$data = \json_encode($data, \JSON_UNESCAPED_SLASHES);
$this->validateLastJson();
}
return \rtrim(\strtr(\base64_encode($data), '+/', '-_'), '=');
} | php | protected function urlSafeEncode($data)
{
if (\is_array($data)) {
$data = \json_encode($data, \JSON_UNESCAPED_SLASHES);
$this->validateLastJson();
}
return \rtrim(\strtr(\base64_encode($data), '+/', '-_'), '=');
} | [
"protected",
"function",
"urlSafeEncode",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"\\",
"json_encode",
"(",
"$",
"data",
",",
"\\",
"JSON_UNESCAPED_SLASHES",
")",
";",
"$",
"this",
"... | URL safe base64 encode.
First serialized the payload as json if it is an array.
@param array|string $data
@throws JWTException When JSON encode fails.
@return string | [
"URL",
"safe",
"base64",
"encode",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/JWT.php#L233-L241 |
adhocore/php-jwt | src/JWT.php | JWT.urlSafeDecode | protected function urlSafeDecode($data, $asJson = true)
{
if (!$asJson) {
return \base64_decode(\strtr($data, '-_', '+/'));
}
$data = \json_decode(\base64_decode(\strtr($data, '-_', '+/')));
$this->validateLastJson();
return $data;
} | php | protected function urlSafeDecode($data, $asJson = true)
{
if (!$asJson) {
return \base64_decode(\strtr($data, '-_', '+/'));
}
$data = \json_decode(\base64_decode(\strtr($data, '-_', '+/')));
$this->validateLastJson();
return $data;
} | [
"protected",
"function",
"urlSafeDecode",
"(",
"$",
"data",
",",
"$",
"asJson",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"asJson",
")",
"{",
"return",
"\\",
"base64_decode",
"(",
"\\",
"strtr",
"(",
"$",
"data",
",",
"'-_'",
",",
"'+/'",
")",
")... | URL safe base64 decode.
@param array|string $data
@param bool $asJson Whether to parse as JSON (defaults to true).
@throws JWTException When JSON encode fails.
@return array|\stdClass|string | [
"URL",
"safe",
"base64",
"decode",
"."
] | train | https://github.com/adhocore/php-jwt/blob/7bbb90d089ac5ef73b4282fc33c7de23403ae6c8/src/JWT.php#L253-L263 |
php-edifact/edifact | src/EDI/Reader.php | Reader.load | public function load(string $url): bool
{
$this->parsedfile = (new Parser($url))->get();
return $this->preValidate();
} | php | public function load(string $url): bool
{
$this->parsedfile = (new Parser($url))->get();
return $this->preValidate();
} | [
"public",
"function",
"load",
"(",
"string",
"$",
"url",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"parsedfile",
"=",
"(",
"new",
"Parser",
"(",
"$",
"url",
")",
")",
"->",
"get",
"(",
")",
";",
"return",
"$",
"this",
"->",
"preValidate",
"(",
")... | @param string $url url to edi file, path to edi file or EDI message
@return bool | [
"@param",
"string",
"$url",
"url",
"to",
"edi",
"file",
"path",
"to",
"edi",
"file",
"or",
"EDI",
"message"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L65-L70 |
php-edifact/edifact | src/EDI/Reader.php | Reader.preValidate | public function preValidate(): bool
{
$this->errors = [];
if (!\is_array($this->parsedfile)) {
$this->errors[] = 'Incorrect format parsed file';
return false;
}
$r = $this->readUNHmessageNumber();
if (!$r && isset($this->errors[0]) && $this->errors[... | php | public function preValidate(): bool
{
$this->errors = [];
if (!\is_array($this->parsedfile)) {
$this->errors[] = 'Incorrect format parsed file';
return false;
}
$r = $this->readUNHmessageNumber();
if (!$r && isset($this->errors[0]) && $this->errors[... | [
"public",
"function",
"preValidate",
"(",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"parsedfile",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
... | Do initial validation
@return bool | [
"Do",
"initial",
"validation"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L89-L108 |
php-edifact/edifact | src/EDI/Reader.php | Reader.splitMultiMessage | public static function splitMultiMessage(string $ediMessage): array
{
// init
$splicedMessages = [];
$message = [];
$unb = false;
foreach (self::unwrap($ediMessage) as $segment) {
if (\strpos($segment, 'UNB') === 0) {
$unb = $segment;
... | php | public static function splitMultiMessage(string $ediMessage): array
{
// init
$splicedMessages = [];
$message = [];
$unb = false;
foreach (self::unwrap($ediMessage) as $segment) {
if (\strpos($segment, 'UNB') === 0) {
$unb = $segment;
... | [
"public",
"static",
"function",
"splitMultiMessage",
"(",
"string",
"$",
"ediMessage",
")",
":",
"array",
"{",
"// init",
"$",
"splicedMessages",
"=",
"[",
"]",
";",
"$",
"message",
"=",
"[",
"]",
";",
"$",
"unb",
"=",
"false",
";",
"foreach",
"(",
"se... | Split multi messages to separate messages
@param string $ediMessage
@return array | [
"Split",
"multi",
"messages",
"to",
"separate",
"messages"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L117-L163 |
php-edifact/edifact | src/EDI/Reader.php | Reader.unwrap | private static function unwrap($string)
{
foreach (\preg_split("/(?<!\?)'/", $string) as &$line) {
$line = \preg_replace('#[\x00\r\n]#', '', $line);
$temp = $line . "'";
if ($temp != "'") {
yield $temp;
}
}
} | php | private static function unwrap($string)
{
foreach (\preg_split("/(?<!\?)'/", $string) as &$line) {
$line = \preg_replace('#[\x00\r\n]#', '', $line);
$temp = $line . "'";
if ($temp != "'") {
yield $temp;
}
}
} | [
"private",
"static",
"function",
"unwrap",
"(",
"$",
"string",
")",
"{",
"foreach",
"(",
"\\",
"preg_split",
"(",
"\"/(?<!\\?)'/\"",
",",
"$",
"string",
")",
"as",
"&",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"\\",
"preg_replace",
"(",
"'#[\\x00\\r\\n]#... | unwrap string splitting rows on terminator (if not escaped)
@param string $string
@return \Generator | [
"unwrap",
"string",
"splitting",
"rows",
"on",
"terminator",
"(",
"if",
"not",
"escaped",
")"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L172-L181 |
php-edifact/edifact | src/EDI/Reader.php | Reader.readEdiDataValueReq | public function readEdiDataValueReq($filter, int $l1, $l2 = false): string
{
return $this->readEdiDataValue($filter, $l1, $l2, true);
} | php | public function readEdiDataValueReq($filter, int $l1, $l2 = false): string
{
return $this->readEdiDataValue($filter, $l1, $l2, true);
} | [
"public",
"function",
"readEdiDataValueReq",
"(",
"$",
"filter",
",",
"int",
"$",
"l1",
",",
"$",
"l2",
"=",
"false",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"readEdiDataValue",
"(",
"$",
"filter",
",",
"$",
"l1",
",",
"$",
"l2",
",",
... | read required value. if no found, registered error
@param string|array $filter segment filter by segment name and values
@param int $l1
@param int|false $l2
@return string | [
"read",
"required",
"value",
".",
"if",
"no",
"found",
"registered",
"error"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L192-L195 |
php-edifact/edifact | src/EDI/Reader.php | Reader.readEdiDataValue | public function readEdiDataValue($filter, int $l1, $l2 = false, bool $required = false)
{
// interpret filter parameters
if (\is_array($filter)) {
$segment_name = $filter[0];
$filter_elements = $filter[1];
} else {
$segment_name = $filter;
$fil... | php | public function readEdiDataValue($filter, int $l1, $l2 = false, bool $required = false)
{
// interpret filter parameters
if (\is_array($filter)) {
$segment_name = $filter[0];
$filter_elements = $filter[1];
} else {
$segment_name = $filter;
$fil... | [
"public",
"function",
"readEdiDataValue",
"(",
"$",
"filter",
",",
"int",
"$",
"l1",
",",
"$",
"l2",
"=",
"false",
",",
"bool",
"$",
"required",
"=",
"false",
")",
"{",
"// interpret filter parameters",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"filter",
")... | read data value from parsed EDI data
@param array|string $filter 'AGR' - segment code
or ['AGR',['1'=>'BB']], where AGR segment code and first element equal 'BB'
or ['AGR',['1.0'=>'BB']], where AGR segment code and first element zero subelement
equal 'BB'
@param int $l1 first level item number (star... | [
"read",
"data",
"value",
"from",
"parsed",
"EDI",
"data"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L210-L317 |
php-edifact/edifact | src/EDI/Reader.php | Reader.readEdiSegmentDTM | public function readEdiSegmentDTM($PeriodQualifier)
{
$date = $this->readEdiDataValue(['DTM', ['1.0' => $PeriodQualifier]], 1, 1);
$format = $this->readEdiDataValue(['DTM', ['1.0' => $PeriodQualifier]], 1, 2);
if (empty($date)) {
return $date;
}
switch ($format) {... | php | public function readEdiSegmentDTM($PeriodQualifier)
{
$date = $this->readEdiDataValue(['DTM', ['1.0' => $PeriodQualifier]], 1, 1);
$format = $this->readEdiDataValue(['DTM', ['1.0' => $PeriodQualifier]], 1, 2);
if (empty($date)) {
return $date;
}
switch ($format) {... | [
"public",
"function",
"readEdiSegmentDTM",
"(",
"$",
"PeriodQualifier",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"readEdiDataValue",
"(",
"[",
"'DTM'",
",",
"[",
"'1.0'",
"=>",
"$",
"PeriodQualifier",
"]",
"]",
",",
"1",
",",
"1",
")",
";",
"$",
... | read date from DTM segment period qualifier - codelist 2005
@param int $PeriodQualifier period qualifier (codelist/2005)
@return string YYYY-MM-DD HH:MM:SS | [
"read",
"date",
"from",
"DTM",
"segment",
"period",
"qualifier",
"-",
"codelist",
"2005"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L326-L344 |
php-edifact/edifact | src/EDI/Reader.php | Reader.readUNBDateTimeOfPreparation | public function readUNBDateTimeOfPreparation()
{
// separate date (YYMMDD) and time (HHMM)
$date = $this->readEdiDataValue('UNB', 4, 0);
if (!empty($date)) {
$time = $this->readEdiDataValue('UNB', 4, 1);
$datetime = \preg_replace('#(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)#', '2... | php | public function readUNBDateTimeOfPreparation()
{
// separate date (YYMMDD) and time (HHMM)
$date = $this->readEdiDataValue('UNB', 4, 0);
if (!empty($date)) {
$time = $this->readEdiDataValue('UNB', 4, 1);
$datetime = \preg_replace('#(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)#', '2... | [
"public",
"function",
"readUNBDateTimeOfPreparation",
"(",
")",
"{",
"// separate date (YYMMDD) and time (HHMM)",
"$",
"date",
"=",
"$",
"this",
"->",
"readEdiDataValue",
"(",
"'UNB'",
",",
"4",
",",
"0",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"date",
... | get message preparation time
@return null|string | [
"get",
"message",
"preparation",
"time"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L367-L383 |
php-edifact/edifact | src/EDI/Reader.php | Reader.readTDTtransportIdentification | public function readTDTtransportIdentification($transportStageQualifier): string
{
$transportIdentification = $this->readEdiDataValue(['TDT', ['1' => $transportStageQualifier]], 8, 0);
if (!empty($transportIdentification)) {
return $transportIdentification;
}
return $thi... | php | public function readTDTtransportIdentification($transportStageQualifier): string
{
$transportIdentification = $this->readEdiDataValue(['TDT', ['1' => $transportStageQualifier]], 8, 0);
if (!empty($transportIdentification)) {
return $transportIdentification;
}
return $thi... | [
"public",
"function",
"readTDTtransportIdentification",
"(",
"$",
"transportStageQualifier",
")",
":",
"string",
"{",
"$",
"transportIdentification",
"=",
"$",
"this",
"->",
"readEdiDataValue",
"(",
"[",
"'TDT'",
",",
"[",
"'1'",
"=>",
"$",
"transportStageQualifier"... | read transport identification number
@param mixed $transportStageQualifier
@return null|string | [
"read",
"transport",
"identification",
"number"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L392-L400 |
php-edifact/edifact | src/EDI/Reader.php | Reader.readGroups | public function readGroups(string $before, string $start, string $end, string $after)
{
// init
$groups = [];
$group = [];
$position = 'before_search';
foreach ($this->parsedfile as $edi_row) {
// search before group segment
if ($position == 'before_s... | php | public function readGroups(string $before, string $start, string $end, string $after)
{
// init
$groups = [];
$group = [];
$position = 'before_search';
foreach ($this->parsedfile as $edi_row) {
// search before group segment
if ($position == 'before_s... | [
"public",
"function",
"readGroups",
"(",
"string",
"$",
"before",
",",
"string",
"$",
"start",
",",
"string",
"$",
"end",
",",
"string",
"$",
"after",
")",
"{",
"// init",
"$",
"groups",
"=",
"[",
"]",
";",
"$",
"group",
"=",
"[",
"]",
";",
"$",
... | Get groups from message.
@param string $before segment before groups
@param string $start first segment of group
@param string $end last segment of group
@param string $after segment after groups
@return false|array | [
"Get",
"groups",
"from",
"message",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L432-L501 |
php-edifact/edifact | src/EDI/Reader.php | Reader.groupsExtract | public function groupsExtract(string $start = 'LIN', array $barrier = ['UNS']): array
{
// init
$groups = [];
$group = [];
$position = 'before_search';
foreach ($this->getParsedFile() as $edi_row) {
$segment = $edi_row[0];
if (
$positi... | php | public function groupsExtract(string $start = 'LIN', array $barrier = ['UNS']): array
{
// init
$groups = [];
$group = [];
$position = 'before_search';
foreach ($this->getParsedFile() as $edi_row) {
$segment = $edi_row[0];
if (
$positi... | [
"public",
"function",
"groupsExtract",
"(",
"string",
"$",
"start",
"=",
"'LIN'",
",",
"array",
"$",
"barrier",
"=",
"[",
"'UNS'",
"]",
")",
":",
"array",
"{",
"// init",
"$",
"groups",
"=",
"[",
"]",
";",
"$",
"group",
"=",
"[",
"]",
";",
"$",
"... | Get groups from message when last segment is unknown but you know the barrier
useful for invoices by default.
@param string $start first segment start a new group
@param array $barrier barrier segment (NOT in group)
@return array | [
"Get",
"groups",
"from",
"message",
"when",
"last",
"segment",
"is",
"unknown",
"but",
"you",
"know",
"the",
"barrier",
"useful",
"for",
"invoices",
"by",
"default",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Reader.php#L512-L548 |
php-edifact/edifact | src/EDI/Parser.php | Parser.parse | public function parse(array &$file2): array
{
$i = 0;
foreach ($file2 as &$line) {
++$i;
// Null byte and carriage return removal. (CR+LF)
$line = str_replace(["\x00", "\r", "\n"], '', $line);
// Basic sanitization, remove non printable chars.
... | php | public function parse(array &$file2): array
{
$i = 0;
foreach ($file2 as &$line) {
++$i;
// Null byte and carriage return removal. (CR+LF)
$line = str_replace(["\x00", "\r", "\n"], '', $line);
// Basic sanitization, remove non printable chars.
... | [
"public",
"function",
"parse",
"(",
"array",
"&",
"$",
"file2",
")",
":",
"array",
"{",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"file2",
"as",
"&",
"$",
"line",
")",
"{",
"++",
"$",
"i",
";",
"// Null byte and carriage return removal. (CR+LF)",
"... | Parse edi array
@param array $file2
@return array | [
"Parse",
"edi",
"array"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L174-L222 |
php-edifact/edifact | src/EDI/Parser.php | Parser.resetUNA | private function resetUNA()
{
$this->sepComp = "\:";
$this->sepUnescapedComp = ":";
$this->sepData = "\+";
$this->sepDec = "."; // See later if a preg_quote is needed
$this->symbRel = "\?";
$this->symbUnescapedRel = "?";
$this->symbRep = "*"; // See later if a... | php | private function resetUNA()
{
$this->sepComp = "\:";
$this->sepUnescapedComp = ":";
$this->sepData = "\+";
$this->sepDec = "."; // See later if a preg_quote is needed
$this->symbRel = "\?";
$this->symbUnescapedRel = "?";
$this->symbRep = "*"; // See later if a... | [
"private",
"function",
"resetUNA",
"(",
")",
"{",
"$",
"this",
"->",
"sepComp",
"=",
"\"\\:\"",
";",
"$",
"this",
"->",
"sepUnescapedComp",
"=",
"\":\"",
";",
"$",
"this",
"->",
"sepData",
"=",
"\"\\+\"",
";",
"$",
"this",
"->",
"sepDec",
"=",
"\".\"",... | Reset UNA's characters definition
@return void | [
"Reset",
"UNA",
"s",
"characters",
"definition"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L229-L241 |
php-edifact/edifact | src/EDI/Parser.php | Parser.analyseUNA | public function analyseUNA(string $line)
{
$line = \substr($line, 0, 6);
if (isset($line[0])) {
$this->sepComp = \preg_quote($line[0], self::$DELIMITER);
$this->sepUnescapedComp = $line[0];
if (isset($line[1])) {
$this->sepData = \preg_quote($line[... | php | public function analyseUNA(string $line)
{
$line = \substr($line, 0, 6);
if (isset($line[0])) {
$this->sepComp = \preg_quote($line[0], self::$DELIMITER);
$this->sepUnescapedComp = $line[0];
if (isset($line[1])) {
$this->sepData = \preg_quote($line[... | [
"public",
"function",
"analyseUNA",
"(",
"string",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"\\",
"substr",
"(",
"$",
"line",
",",
"0",
",",
"6",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"line",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",... | Read UNA's characters definition
@param string $line : UNA definition line (without UNA tag). Example : :+.? '
@return void | [
"Read",
"UNA",
"s",
"characters",
"definition"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L261-L285 |
php-edifact/edifact | src/EDI/Parser.php | Parser.analyseUNB | public function analyseUNB($encoding)
{
if (\is_array($encoding)) {
$encoding = $encoding[0];
}
$this->encoding = $encoding;
// If there's a regex defined for this character set, use it.
/** @noinspection OffsetOperationsInspection */
if (isset(self::$en... | php | public function analyseUNB($encoding)
{
if (\is_array($encoding)) {
$encoding = $encoding[0];
}
$this->encoding = $encoding;
// If there's a regex defined for this character set, use it.
/** @noinspection OffsetOperationsInspection */
if (isset(self::$en... | [
"public",
"function",
"analyseUNB",
"(",
"$",
"encoding",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"encoding",
")",
")",
"{",
"$",
"encoding",
"=",
"$",
"encoding",
"[",
"0",
"]",
";",
"}",
"$",
"this",
"->",
"encoding",
"=",
"$",
"encoding... | UNB line analysis
@param string|string[] $encoding UNB definition line (without UNB tag). Example UNOA:2
@return void | [
"UNB",
"line",
"analysis"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L294-L310 |
php-edifact/edifact | src/EDI/Parser.php | Parser.analyseUNH | public function analyseUNH(array $line)
{
if (\count($line) < 3) {
return;
}
$lineElement = $line[2];
if (!\is_array($lineElement)) {
$this->messageFormat = $lineElement;
return;
}
$this->messageFormat = $lineElement[0];
... | php | public function analyseUNH(array $line)
{
if (\count($line) < 3) {
return;
}
$lineElement = $line[2];
if (!\is_array($lineElement)) {
$this->messageFormat = $lineElement;
return;
}
$this->messageFormat = $lineElement[0];
... | [
"public",
"function",
"analyseUNH",
"(",
"array",
"$",
"line",
")",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"line",
")",
"<",
"3",
")",
"{",
"return",
";",
"}",
"$",
"lineElement",
"=",
"$",
"line",
"[",
"2",
"]",
";",
"if",
"(",
"!",
"\\",
... | Identify message type
@param string[] $line UNH segment
@return void | [
"Identify",
"message",
"type"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L319-L334 |
php-edifact/edifact | src/EDI/Parser.php | Parser.unwrap | private function unwrap(string &$string): array
{
if (
!$this->unaChecked
&&
\strpos($string, 'UNA') === 0
) {
$this->analyseUNA(
\substr(\substr($string, 3), 0, 9)
);
}
if (
!$this->unbChecked
... | php | private function unwrap(string &$string): array
{
if (
!$this->unaChecked
&&
\strpos($string, 'UNA') === 0
) {
$this->analyseUNA(
\substr(\substr($string, 3), 0, 9)
);
}
if (
!$this->unbChecked
... | [
"private",
"function",
"unwrap",
"(",
"string",
"&",
"$",
"string",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"unaChecked",
"&&",
"\\",
"strpos",
"(",
"$",
"string",
",",
"'UNA'",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"an... | Unwrap string splitting rows on terminator (if not escaped)
@param string $string
@return string[] | [
"Unwrap",
"string",
"splitting",
"rows",
"on",
"terminator",
"(",
"if",
"not",
"escaped",
")"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L343-L394 |
php-edifact/edifact | src/EDI/Parser.php | Parser.splitSegment | private function splitSegment(string &$str): array
{
// remove ending "symbEnd"
$str = \trim(
\preg_replace(
self::$DELIMITER . $this->symbEnd . '$' . self::$DELIMITER,
'',
$str
)
);
// replace duplicate "symbRe... | php | private function splitSegment(string &$str): array
{
// remove ending "symbEnd"
$str = \trim(
\preg_replace(
self::$DELIMITER . $this->symbEnd . '$' . self::$DELIMITER,
'',
$str
)
);
// replace duplicate "symbRe... | [
"private",
"function",
"splitSegment",
"(",
"string",
"&",
"$",
"str",
")",
":",
"array",
"{",
"// remove ending \"symbEnd\"",
"$",
"str",
"=",
"\\",
"trim",
"(",
"\\",
"preg_replace",
"(",
"self",
"::",
"$",
"DELIMITER",
".",
"$",
"this",
"->",
"symbEnd",... | Segments
@param string $str
@return array|string[] | [
"Segments"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L403-L462 |
php-edifact/edifact | src/EDI/Parser.php | Parser.splitData | private function splitData(string &$str)
{
if ($str === '') {
return $str;
}
$replace = function (&$string) {
if (\strpos($string, $this->symbUnescapedRel) !== false) {
$string = \preg_replace(
self::$DELIMITER . $this->symbRel . ... | php | private function splitData(string &$str)
{
if ($str === '') {
return $str;
}
$replace = function (&$string) {
if (\strpos($string, $this->symbUnescapedRel) !== false) {
$string = \preg_replace(
self::$DELIMITER . $this->symbRel . ... | [
"private",
"function",
"splitData",
"(",
"string",
"&",
"$",
"str",
")",
"{",
"if",
"(",
"$",
"str",
"===",
"''",
")",
"{",
"return",
"$",
"str",
";",
"}",
"$",
"replace",
"=",
"function",
"(",
"&",
"$",
"string",
")",
"{",
"if",
"(",
"\\",
"st... | Composite data element
@param string $str
@return mixed | [
"Composite",
"data",
"element"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L471-L518 |
php-edifact/edifact | src/EDI/Parser.php | Parser.loadString | public function loadString(&$string): array
{
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$string = $this->unwrap($string);
$this->rawSegments = $string;
return $this->parse($string);
} | php | public function loadString(&$string): array
{
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
$string = $this->unwrap($string);
$this->rawSegments = $string;
return $this->parse($string);
} | [
"public",
"function",
"loadString",
"(",
"&",
"$",
"string",
")",
":",
"array",
"{",
"/** @noinspection CallableParameterUseCaseInTypeContextInspection */",
"$",
"string",
"=",
"$",
"this",
"->",
"unwrap",
"(",
"$",
"string",
")",
";",
"$",
"this",
"->",
"rawSeg... | Load the message from a string.
@param string $string
@return array | [
"Load",
"the",
"message",
"from",
"a",
"string",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Parser.php#L571-L578 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.loadMessageXml | public function loadMessageXml(string $message_xml_file): array
{
$messageXmlString = \file_get_contents($message_xml_file);
$messageXml = new \SimpleXMLIterator($messageXmlString);
unset($messageXmlString);
$message = [
"defaults" => $this->readMessageDefaults($messageXm... | php | public function loadMessageXml(string $message_xml_file): array
{
$messageXmlString = \file_get_contents($message_xml_file);
$messageXml = new \SimpleXMLIterator($messageXmlString);
unset($messageXmlString);
$message = [
"defaults" => $this->readMessageDefaults($messageXm... | [
"public",
"function",
"loadMessageXml",
"(",
"string",
"$",
"message_xml_file",
")",
":",
"array",
"{",
"$",
"messageXmlString",
"=",
"\\",
"file_get_contents",
"(",
"$",
"message_xml_file",
")",
";",
"$",
"messageXml",
"=",
"new",
"\\",
"SimpleXMLIterator",
"("... | @param string $message_xml_file
@return array | [
"@param",
"string",
"$message_xml_file"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L22-L34 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.readMessageDefaults | protected function readMessageDefaults(\SimpleXMLElement $message): array
{
// init
$defaults = [];
/* @var \SimpleXMLElement $defaultValueNode */
foreach ($message->defaults[0] ?? [] as $defaultValueNode) {
$attributes = $defaultValueNode->attributes();
$id ... | php | protected function readMessageDefaults(\SimpleXMLElement $message): array
{
// init
$defaults = [];
/* @var \SimpleXMLElement $defaultValueNode */
foreach ($message->defaults[0] ?? [] as $defaultValueNode) {
$attributes = $defaultValueNode->attributes();
$id ... | [
"protected",
"function",
"readMessageDefaults",
"(",
"\\",
"SimpleXMLElement",
"$",
"message",
")",
":",
"array",
"{",
"// init",
"$",
"defaults",
"=",
"[",
"]",
";",
"/* @var \\SimpleXMLElement $defaultValueNode */",
"foreach",
"(",
"$",
"message",
"->",
"defaults"... | read default values in given message xml
@param \SimpleXMLElement $message
@return array | [
"read",
"default",
"values",
"in",
"given",
"message",
"xml"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L43-L56 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.readXmlNodes | protected function readXmlNodes(\SimpleXMLElement $element): array
{
$arrayElements = [];
foreach ($element as $name => $node) {
if ($name == "defaults") {
continue;
}
$arrayElement = [];
$arrayElement["type"] = $name;
$arra... | php | protected function readXmlNodes(\SimpleXMLElement $element): array
{
$arrayElements = [];
foreach ($element as $name => $node) {
if ($name == "defaults") {
continue;
}
$arrayElement = [];
$arrayElement["type"] = $name;
$arra... | [
"protected",
"function",
"readXmlNodes",
"(",
"\\",
"SimpleXMLElement",
"$",
"element",
")",
":",
"array",
"{",
"$",
"arrayElements",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"element",
"as",
"$",
"name",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"$",
... | read message segments and groups
@param \SimpleXMLElement $element
@return array | [
"read",
"message",
"segments",
"and",
"groups"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L65-L83 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.readAttributesArray | protected function readAttributesArray(\SimpleXMLElement $element): array
{
$attributes = [];
foreach ($element->attributes() as $attrName => $attr) {
$attributes[(string)$attrName] = (string)$attr;
}
return $attributes;
} | php | protected function readAttributesArray(\SimpleXMLElement $element): array
{
$attributes = [];
foreach ($element->attributes() as $attrName => $attr) {
$attributes[(string)$attrName] = (string)$attr;
}
return $attributes;
} | [
"protected",
"function",
"readAttributesArray",
"(",
"\\",
"SimpleXMLElement",
"$",
"element",
")",
":",
"array",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"element",
"->",
"attributes",
"(",
")",
"as",
"$",
"attrName",
"=>",
"$",
... | return an xml elements attributes in as array
@param \SimpleXMLElement $element
@return array | [
"return",
"an",
"xml",
"elements",
"attributes",
"in",
"as",
"array"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L92-L100 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.loadCodesXml | public function loadCodesXml(string $codesXml): array
{
$codesXmlString = \file_get_contents($codesXml);
$codesXml = new \SimpleXMLIterator($codesXmlString);
unset($codesXmlString);
$codes = [];
/* @var \SimpleXmlIterator $codeCollection */
foreach ($codesXml as $code... | php | public function loadCodesXml(string $codesXml): array
{
$codesXmlString = \file_get_contents($codesXml);
$codesXml = new \SimpleXMLIterator($codesXmlString);
unset($codesXmlString);
$codes = [];
/* @var \SimpleXmlIterator $codeCollection */
foreach ($codesXml as $code... | [
"public",
"function",
"loadCodesXml",
"(",
"string",
"$",
"codesXml",
")",
":",
"array",
"{",
"$",
"codesXmlString",
"=",
"\\",
"file_get_contents",
"(",
"$",
"codesXml",
")",
";",
"$",
"codesXml",
"=",
"new",
"\\",
"SimpleXMLIterator",
"(",
"$",
"codesXmlSt... | get all data element codes
@param string $codesXml
@return array | [
"get",
"all",
"data",
"element",
"codes"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L109-L128 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.loadSegmentsXml | public function loadSegmentsXml(string $segment_xml_file): array
{
$segments_xml = \file_get_contents($segment_xml_file);
$xml = \simplexml_load_string($segments_xml);
unset($segments_xml);
$this->segments = [];
/* @var \SimpleXMLElement $segmentNode */
foreach ($xm... | php | public function loadSegmentsXml(string $segment_xml_file): array
{
$segments_xml = \file_get_contents($segment_xml_file);
$xml = \simplexml_load_string($segments_xml);
unset($segments_xml);
$this->segments = [];
/* @var \SimpleXMLElement $segmentNode */
foreach ($xm... | [
"public",
"function",
"loadSegmentsXml",
"(",
"string",
"$",
"segment_xml_file",
")",
":",
"array",
"{",
"$",
"segments_xml",
"=",
"\\",
"file_get_contents",
"(",
"$",
"segment_xml_file",
")",
";",
"$",
"xml",
"=",
"\\",
"simplexml_load_string",
"(",
"$",
"seg... | convert segment definition from XML to array. Sequence of data_elements and
composite_data_element same as in XML
@param string $segment_xml_file
@return array | [
"convert",
"segment",
"definition",
"from",
"XML",
"to",
"array",
".",
"Sequence",
"of",
"data_elements",
"and",
"composite_data_element",
"same",
"as",
"in",
"XML"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L138-L159 |
php-edifact/edifact | src/EDI/Analyser.php | Analyser.process | public function process(array $data, array $rawSegments = null): string
{
$r = [];
foreach ($data as $nrow => $segment) {
$id = $segment[0];
$r[] = '';
$jsonsegment = [];
if (isset($rawSegments[$nrow])) {
$r[] = \trim($rawSegments[$nr... | php | public function process(array $data, array $rawSegments = null): string
{
$r = [];
foreach ($data as $nrow => $segment) {
$id = $segment[0];
$r[] = '';
$jsonsegment = [];
if (isset($rawSegments[$nrow])) {
$r[] = \trim($rawSegments[$nr... | [
"public",
"function",
"process",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"rawSegments",
"=",
"null",
")",
":",
"string",
"{",
"$",
"r",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"nrow",
"=>",
"$",
"segment",
")",
"{",
"$",... | create readable EDI MESSAGE with comments
@param array $data by EDI\Parser:parse() created array from plain EDI message
@param array $rawSegments (optional) List of raw segments from EDI\Parser::getRawSegments
@return string file | [
"create",
"readable",
"EDI",
"MESSAGE",
"with",
"comments"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Analyser.php#L169-L263 |
php-edifact/edifact | src/EDI/Encoder.php | Encoder.encode | public function encode(array $array, $wrap = true, $filterKeys = false): string
{
$this->originalArray = $array;
$this->wrap = $wrap;
$edistring = '';
$count = \count($array);
$k = 0;
foreach ($array as $row) {
$k++;
if ($filterKeys) {
... | php | public function encode(array $array, $wrap = true, $filterKeys = false): string
{
$this->originalArray = $array;
$this->wrap = $wrap;
$edistring = '';
$count = \count($array);
$k = 0;
foreach ($array as $row) {
$k++;
if ($filterKeys) {
... | [
"public",
"function",
"encode",
"(",
"array",
"$",
"array",
",",
"$",
"wrap",
"=",
"true",
",",
"$",
"filterKeys",
"=",
"false",
")",
":",
"string",
"{",
"$",
"this",
"->",
"originalArray",
"=",
"$",
"array",
";",
"$",
"this",
"->",
"wrap",
"=",
"$... | @param array $array
@param bool $wrap
@param bool $filterKeys
@return string | [
"@param",
"array",
"$array",
"@param",
"bool",
"$wrap",
"@param",
"bool",
"$filterKeys"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Encoder.php#L87-L109 |
php-edifact/edifact | src/EDI/Encoder.php | Encoder.encodeSegment | public function encodeSegment(array $row): string
{
// init
$str = '';
$t = \count($row);
foreach ($row as $i => &$iValue) {
if (\is_array($iValue)) {
if (\count($iValue) === 1
&& \is_array(\reset($iValue))
) {
... | php | public function encodeSegment(array $row): string
{
// init
$str = '';
$t = \count($row);
foreach ($row as $i => &$iValue) {
if (\is_array($iValue)) {
if (\count($iValue) === 1
&& \is_array(\reset($iValue))
) {
... | [
"public",
"function",
"encodeSegment",
"(",
"array",
"$",
"row",
")",
":",
"string",
"{",
"// init",
"$",
"str",
"=",
"''",
";",
"$",
"t",
"=",
"\\",
"count",
"(",
"$",
"row",
")",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"i",
"=>",
"&",
"$"... | @param array $row
@return string | [
"@param",
"array",
"$row"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Encoder.php#L116-L153 |
php-edifact/edifact | src/EDI/Encoder.php | Encoder.escapeValue | private function escapeValue(&$str): string
{
$search = [
$this->symbRel,
$this->sepComp,
$this->sepData,
$this->symbEnd,
];
$replace = [
$this->symbRel . $this->symbRel,
$this->symbRel . $this->sepComp,
$thi... | php | private function escapeValue(&$str): string
{
$search = [
$this->symbRel,
$this->sepComp,
$this->sepData,
$this->symbEnd,
];
$replace = [
$this->symbRel . $this->symbRel,
$this->symbRel . $this->sepComp,
$thi... | [
"private",
"function",
"escapeValue",
"(",
"&",
"$",
"str",
")",
":",
"string",
"{",
"$",
"search",
"=",
"[",
"$",
"this",
"->",
"symbRel",
",",
"$",
"this",
"->",
"sepComp",
",",
"$",
"this",
"->",
"sepData",
",",
"$",
"this",
"->",
"symbEnd",
","... | @param string|int $str
@return string | [
"@param",
"string|int",
"$str"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Encoder.php#L160-L176 |
php-edifact/edifact | src/EDI/Encoder.php | Encoder.setUNA | public function setUNA(string $chars, bool $user_call = true): bool
{
if (\is_string($chars)
&& \strlen($chars) == 6
) {
$this->sepComp = $chars[0];
$this->sepData = $chars[1];
$this->sepDec = $chars[2];
$this->symbRel = $chars[3];
... | php | public function setUNA(string $chars, bool $user_call = true): bool
{
if (\is_string($chars)
&& \strlen($chars) == 6
) {
$this->sepComp = $chars[0];
$this->sepData = $chars[1];
$this->sepDec = $chars[2];
$this->symbRel = $chars[3];
... | [
"public",
"function",
"setUNA",
"(",
"string",
"$",
"chars",
",",
"bool",
"$",
"user_call",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"chars",
")",
"&&",
"\\",
"strlen",
"(",
"$",
"chars",
")",
"==",
"6",
")",
"{... | @param string $chars
@param bool $user_call
@return bool | [
"@param",
"string",
"$chars",
"@param",
"bool",
"$user_call"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Encoder.php#L206-L230 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.prepare | public function prepare(array $parsed): array
{
$this->msgs = $this->splitMessages($parsed, $this->errors);
$groups = [];
$service = $this->msgs['service'];
$this->serviceSeg = $this->processService($service);
foreach ($this->msgs as $k => $msg) {
if ($k === 'ser... | php | public function prepare(array $parsed): array
{
$this->msgs = $this->splitMessages($parsed, $this->errors);
$groups = [];
$service = $this->msgs['service'];
$this->serviceSeg = $this->processService($service);
foreach ($this->msgs as $k => $msg) {
if ($k === 'ser... | [
"public",
"function",
"prepare",
"(",
"array",
"$",
"parsed",
")",
":",
"array",
"{",
"$",
"this",
"->",
"msgs",
"=",
"$",
"this",
"->",
"splitMessages",
"(",
"$",
"parsed",
",",
"$",
"this",
"->",
"errors",
")",
";",
"$",
"groups",
"=",
"[",
"]",
... | Split multiple messages and process
@param array $parsed An array coming from EDI\Parser
@return array | [
"Split",
"multiple",
"messages",
"and",
"process"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L161-L178 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.splitMessages | private function splitMessages(&$parsed, &$errors): array
{
// init
$messages = [];
$tmpmsg = [];
$service = [];
$hasInterchangeDelimiters = 0;
$hasMessageDelimiters = 0;
foreach ($parsed as $c => $segment) {
switch ($segment[0]) {
... | php | private function splitMessages(&$parsed, &$errors): array
{
// init
$messages = [];
$tmpmsg = [];
$service = [];
$hasInterchangeDelimiters = 0;
$hasMessageDelimiters = 0;
foreach ($parsed as $c => $segment) {
switch ($segment[0]) {
... | [
"private",
"function",
"splitMessages",
"(",
"&",
"$",
"parsed",
",",
"&",
"$",
"errors",
")",
":",
"array",
"{",
"// init",
"$",
"messages",
"=",
"[",
"]",
";",
"$",
"tmpmsg",
"=",
"[",
"]",
";",
"$",
"service",
"=",
"[",
"]",
";",
"$",
"hasInte... | Split multiple messages
@param array $parsed An array coming from EDI\Parser
@param array $errors
@return array | [
"Split",
"multiple",
"messages"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L188-L261 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.loopMessage | private function loopMessage(array &$message, \SimpleXMLElement $xml, array &$errors): array
{
// init
$groupedEdi = [];
$segmentIdx = 0;
foreach ($xml->children() as $elm) {
if ($elm->getName() == "group") {
$this->processXmlGroup($elm, $message, $segmen... | php | private function loopMessage(array &$message, \SimpleXMLElement $xml, array &$errors): array
{
// init
$groupedEdi = [];
$segmentIdx = 0;
foreach ($xml->children() as $elm) {
if ($elm->getName() == "group") {
$this->processXmlGroup($elm, $message, $segmen... | [
"private",
"function",
"loopMessage",
"(",
"array",
"&",
"$",
"message",
",",
"\\",
"SimpleXMLElement",
"$",
"xml",
",",
"array",
"&",
"$",
"errors",
")",
":",
"array",
"{",
"// init",
"$",
"groupedEdi",
"=",
"[",
"]",
";",
"$",
"segmentIdx",
"=",
"0",... | Transform a parsed edi in its groupings
@param array $message Single message (Without UNB and UNZ)
@param \SimpleXMLElement $xml The xml representation of the message
@param array $errors
@return array | [
"Transform",
"a",
"parsed",
"edi",
"in",
"its",
"groupings"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L272-L293 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.processXmlGroup | private function processXmlGroup(\SimpleXMLElement $elm, array &$message, int &$segmentIdx, array &$array, array &$errors)
{
// init
$groupVisited = false;
$newGroup = [];
for ($g = 0; $g < $elm['maxrepeat']; $g++) {
$grouptemp = [];
if ($message[$segmentIdx]... | php | private function processXmlGroup(\SimpleXMLElement $elm, array &$message, int &$segmentIdx, array &$array, array &$errors)
{
// init
$groupVisited = false;
$newGroup = [];
for ($g = 0; $g < $elm['maxrepeat']; $g++) {
$grouptemp = [];
if ($message[$segmentIdx]... | [
"private",
"function",
"processXmlGroup",
"(",
"\\",
"SimpleXMLElement",
"$",
"elm",
",",
"array",
"&",
"$",
"message",
",",
"int",
"&",
"$",
"segmentIdx",
",",
"array",
"&",
"$",
"array",
",",
"array",
"&",
"$",
"errors",
")",
"{",
"// init",
"$",
"gr... | Process an XML Group
@param \SimpleXMLElement $elm
@param array $message
@param int $segmentIdx
@param array $array
@param array $errors
@return void | [
"Process",
"an",
"XML",
"Group"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L306-L355 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.processXmlSegment | private function processXmlSegment(\SimpleXMLElement $elm, array &$message, int &$segmentIdx, array &$array, array &$errors)
{
// init
$segmentVisited = false;
for ($i = 0; $i < $elm['maxrepeat']; $i++) {
if (\call_user_func($this->comparisonFunction, $message[$segmentIdx], $el... | php | private function processXmlSegment(\SimpleXMLElement $elm, array &$message, int &$segmentIdx, array &$array, array &$errors)
{
// init
$segmentVisited = false;
for ($i = 0; $i < $elm['maxrepeat']; $i++) {
if (\call_user_func($this->comparisonFunction, $message[$segmentIdx], $el... | [
"private",
"function",
"processXmlSegment",
"(",
"\\",
"SimpleXMLElement",
"$",
"elm",
",",
"array",
"&",
"$",
"message",
",",
"int",
"&",
"$",
"segmentIdx",
",",
"array",
"&",
"$",
"array",
",",
"array",
"&",
"$",
"errors",
")",
"{",
"// init",
"$",
"... | Process an XML Segment.
@param \SimpleXMLElement $elm
@param array $message
@param int $segmentIdx
@param array $array
@param array $errors
@return void | [
"Process",
"an",
"XML",
"Segment",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L368-L409 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.doAddArray | private function doAddArray(array &$array, array &$jsonMessage)
{
if (isset($array[$jsonMessage['key']])) {
if (
isset($array[$jsonMessage['key']]['segmentCode'])
||
$jsonMessage['key'] === 'UnrecognisedType'
) {
$temp =... | php | private function doAddArray(array &$array, array &$jsonMessage)
{
if (isset($array[$jsonMessage['key']])) {
if (
isset($array[$jsonMessage['key']]['segmentCode'])
||
$jsonMessage['key'] === 'UnrecognisedType'
) {
$temp =... | [
"private",
"function",
"doAddArray",
"(",
"array",
"&",
"$",
"array",
",",
"array",
"&",
"$",
"jsonMessage",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"jsonMessage",
"[",
"'key'",
"]",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
... | Adds a processed segment to the current group.
@param array $array a reference to the group
@param array $jsonMessage a segment processed by processSegment()
@return void | [
"Adds",
"a",
"processed",
"segment",
"to",
"the",
"current",
"group",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L419-L435 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.processSegment | private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, array &$errors = null): array
{
$id = $segment[0];
$jsonsegment = [];
if (isset($xmlMap[$id])) {
$attributes = $xmlMap[$id]['attributes'];
$details_desc = $xmlMap[$id]['details'];
... | php | private function processSegment(array &$segment, array &$xmlMap, $segmentIdx, array &$errors = null): array
{
$id = $segment[0];
$jsonsegment = [];
if (isset($xmlMap[$id])) {
$attributes = $xmlMap[$id]['attributes'];
$details_desc = $xmlMap[$id]['details'];
... | [
"private",
"function",
"processSegment",
"(",
"array",
"&",
"$",
"segment",
",",
"array",
"&",
"$",
"xmlMap",
",",
"$",
"segmentIdx",
",",
"array",
"&",
"$",
"errors",
"=",
"null",
")",
":",
"array",
"{",
"$",
"id",
"=",
"$",
"segment",
"[",
"0",
"... | Add human readable keys as in Analyser.
@param array $segment
@param array $xmlMap
@param null|int $segmentIdx
@param null|array $errors
@return array | [
"Add",
"human",
"readable",
"keys",
"as",
"in",
"Analyser",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L447-L533 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.processService | private function processService(array &$segments): array
{
// init
$processed = [];
foreach ($segments as &$seg) {
$jsonsegment = $this->processSegment($seg, $this->xmlSvc, null);
$processed[$jsonsegment['key']] = $jsonsegment['value'];
}
return $pro... | php | private function processService(array &$segments): array
{
// init
$processed = [];
foreach ($segments as &$seg) {
$jsonsegment = $this->processSegment($seg, $this->xmlSvc, null);
$processed[$jsonsegment['key']] = $jsonsegment['value'];
}
return $pro... | [
"private",
"function",
"processService",
"(",
"array",
"&",
"$",
"segments",
")",
":",
"array",
"{",
"// init",
"$",
"processed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"segments",
"as",
"&",
"$",
"seg",
")",
"{",
"$",
"jsonsegment",
"=",
"$",
"thi... | Process UNB / UNZ segments
@param array $segments
@return array | [
"Process",
"UNB",
"/",
"UNZ",
"segments"
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L542-L553 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.getJson | public function getJson(bool $pretty = false)
{
if ($pretty) {
return \json_encode($this->ediGroups, JSON_PRETTY_PRINT);
}
return \json_encode($this->ediGroups);
} | php | public function getJson(bool $pretty = false)
{
if ($pretty) {
return \json_encode($this->ediGroups, JSON_PRETTY_PRINT);
}
return \json_encode($this->ediGroups);
} | [
"public",
"function",
"getJson",
"(",
"bool",
"$",
"pretty",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"pretty",
")",
"{",
"return",
"\\",
"json_encode",
"(",
"$",
"this",
"->",
"ediGroups",
",",
"JSON_PRETTY_PRINT",
")",
";",
"}",
"return",
"\\",
"json_... | Get result as json.
@param bool $pretty
@return false|string | [
"Get",
"result",
"as",
"json",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L562-L569 |
php-edifact/edifact | src/EDI/Interpreter.php | Interpreter.getJsonServiceSegments | public function getJsonServiceSegments(bool $pretty = false)
{
if ($pretty) {
return \json_encode($this->serviceSeg, JSON_PRETTY_PRINT);
}
return \json_encode($this->serviceSeg);
} | php | public function getJsonServiceSegments(bool $pretty = false)
{
if ($pretty) {
return \json_encode($this->serviceSeg, JSON_PRETTY_PRINT);
}
return \json_encode($this->serviceSeg);
} | [
"public",
"function",
"getJsonServiceSegments",
"(",
"bool",
"$",
"pretty",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"pretty",
")",
"{",
"return",
"\\",
"json_encode",
"(",
"$",
"this",
"->",
"serviceSeg",
",",
"JSON_PRETTY_PRINT",
")",
";",
"}",
"return",
... | Get json service segments.
@param bool $pretty
@return false|string | [
"Get",
"json",
"service",
"segments",
"."
] | train | https://github.com/php-edifact/edifact/blob/a24b01089f63f84e607caddf0e34cad307ac230c/src/EDI/Interpreter.php#L618-L625 |
byjg/migration | src/Migration.php | Migration.getMigrationSql | public function getMigrationSql($version, $increment)
{
// I could use the GLOB_BRACE but it is not supported on ALPINE distros.
// So, I have to call multiple times to simulate the braces.
if (intval($version) != $version) {
throw new \InvalidArgumentException("Version '$versio... | php | public function getMigrationSql($version, $increment)
{
// I could use the GLOB_BRACE but it is not supported on ALPINE distros.
// So, I have to call multiple times to simulate the braces.
if (intval($version) != $version) {
throw new \InvalidArgumentException("Version '$versio... | [
"public",
"function",
"getMigrationSql",
"(",
"$",
"version",
",",
"$",
"increment",
")",
"{",
"// I could use the GLOB_BRACE but it is not supported on ALPINE distros.",
"// So, I have to call multiple times to simulate the braces.",
"if",
"(",
"intval",
"(",
"$",
"version",
"... | Get the full path script based on the version
@param $version
@param $increment
@return string
@throws \ByJG\DbMigration\Exception\InvalidMigrationFile | [
"Get",
"the",
"full",
"path",
"script",
"based",
"on",
"the",
"version"
] | train | https://github.com/byjg/migration/blob/41f0642f5a9697fc2d99123c58e0e9f4fa26ad58/src/Migration.php#L136-L166 |
byjg/migration | src/Migration.php | Migration.reset | public function reset($upVersion = null)
{
if ($this->callableProgress) {
call_user_func_array($this->callableProgress, ['reset', 0]);
}
$this->getDbCommand()->dropDatabase();
$this->getDbCommand()->createDatabase();
$this->getDbCommand()->createVersion();
... | php | public function reset($upVersion = null)
{
if ($this->callableProgress) {
call_user_func_array($this->callableProgress, ['reset', 0]);
}
$this->getDbCommand()->dropDatabase();
$this->getDbCommand()->createDatabase();
$this->getDbCommand()->createVersion();
... | [
"public",
"function",
"reset",
"(",
"$",
"upVersion",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"callableProgress",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"callableProgress",
",",
"[",
"'reset'",
",",
"0",
"]",
")",
";",
"... | Restore the database using the "base.sql" script and run all migration scripts
Note: the database must exists. If dont exist run the method prepareEnvironment
@param int $upVersion
@throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
@throws \ByJG\DbMigration\Exception\DatabaseIsIncompleteException
@throws \B... | [
"Restore",
"the",
"database",
"using",
"the",
"base",
".",
"sql",
"script",
"and",
"run",
"all",
"migration",
"scripts",
"Note",
":",
"the",
"database",
"must",
"exists",
".",
"If",
"dont",
"exist",
"run",
"the",
"method",
"prepareEnvironment"
] | train | https://github.com/byjg/migration/blob/41f0642f5a9697fc2d99123c58e0e9f4fa26ad58/src/Migration.php#L190-L205 |
byjg/migration | src/Migration.php | Migration.migrate | protected function migrate($upVersion, $increment, $force)
{
$versionInfo = $this->getCurrentVersion();
$currentVersion = intval($versionInfo['version']) + $increment;
if (strpos($versionInfo['status'], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) {
throw new Databas... | php | protected function migrate($upVersion, $increment, $force)
{
$versionInfo = $this->getCurrentVersion();
$currentVersion = intval($versionInfo['version']) + $increment;
if (strpos($versionInfo['status'], Migration::VERSION_STATUS_PARTIAL) !== false && !$force) {
throw new Databas... | [
"protected",
"function",
"migrate",
"(",
"$",
"upVersion",
",",
"$",
"increment",
",",
"$",
"force",
")",
"{",
"$",
"versionInfo",
"=",
"$",
"this",
"->",
"getCurrentVersion",
"(",
")",
";",
"$",
"currentVersion",
"=",
"intval",
"(",
"$",
"versionInfo",
... | Method for execute the migration.
@param int $upVersion
@param int $increment Can accept 1 for UP or -1 for down
@param bool $force
@throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
@throws \ByJG\DbMigration\Exception\DatabaseIsIncompleteException
@throws \ByJG\DbMigration\Exception\DatabaseNotVersionedExc... | [
"Method",
"for",
"execute",
"the",
"migration",
"."
] | train | https://github.com/byjg/migration/blob/41f0642f5a9697fc2d99123c58e0e9f4fa26ad58/src/Migration.php#L265-L286 |
byjg/migration | src/Migration.php | Migration.update | public function update($upVersion = null, $force = false)
{
$versionInfo = $this->getCurrentVersion();
$version = intval($versionInfo['version']);
$increment = 1;
if ($upVersion !== null && $upVersion < $version) {
$increment = -1;
}
$this->migrate($upVers... | php | public function update($upVersion = null, $force = false)
{
$versionInfo = $this->getCurrentVersion();
$version = intval($versionInfo['version']);
$increment = 1;
if ($upVersion !== null && $upVersion < $version) {
$increment = -1;
}
$this->migrate($upVers... | [
"public",
"function",
"update",
"(",
"$",
"upVersion",
"=",
"null",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"versionInfo",
"=",
"$",
"this",
"->",
"getCurrentVersion",
"(",
")",
";",
"$",
"version",
"=",
"intval",
"(",
"$",
"versionInfo",
"[",
... | Run all scripts to up or down the database version from current up to latest version or the specified version.
@param int $upVersion
@param bool $force
@throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
@throws \ByJG\DbMigration\Exception\DatabaseIsIncompleteException
@throws \ByJG\DbMigration\Exception\Dat... | [
"Run",
"all",
"scripts",
"to",
"up",
"or",
"down",
"the",
"database",
"version",
"from",
"current",
"up",
"to",
"latest",
"version",
"or",
"the",
"specified",
"version",
"."
] | train | https://github.com/byjg/migration/blob/41f0642f5a9697fc2d99123c58e0e9f4fa26ad58/src/Migration.php#L315-L324 |
winzou/StateMachineBundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$configNode = $treeBuilder
->root('winzou_state_machine')
->useAttributeAsKey('name')
->prototype('array')
->children()
;
$configNode
->scalarNode(... | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$configNode = $treeBuilder
->root('winzou_state_machine')
->useAttributeAsKey('name')
->prototype('array')
->children()
;
$configNode
->scalarNode(... | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"configNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'winzou_state_machine'",
")",
"->",
"useAttributeAsKey",
"(",
"'name'",
"... | {@inheritDoc} | [
"{"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/DependencyInjection/Configuration.php#L23-L48 |
winzou/StateMachineBundle | Callback/ContainerAwareCallback.php | ContainerAwareCallback.call | public function call(TransitionEvent $event)
{
// Load the services only now (when the callback is actually called)
if (is_array($this->callable) && is_string($this->callable[0])) {
if (0 === strpos($this->callable[0], '@')) {
// BC for sf < 4.0, we refer to the service v... | php | public function call(TransitionEvent $event)
{
// Load the services only now (when the callback is actually called)
if (is_array($this->callable) && is_string($this->callable[0])) {
if (0 === strpos($this->callable[0], '@')) {
// BC for sf < 4.0, we refer to the service v... | [
"public",
"function",
"call",
"(",
"TransitionEvent",
"$",
"event",
")",
"{",
"// Load the services only now (when the callback is actually called)",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"callable",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"callable... | {@inheritDoc} | [
"{"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/Callback/ContainerAwareCallback.php#L35-L56 |
winzou/StateMachineBundle | DependencyInjection/winzouStateMachineExtension.php | winzouStateMachineExtension.parseConfig | public function parseConfig(array $configs)
{
foreach ($configs as &$config) {
$config['states'] = $this->parseStates($config['states']);
if (isset($config['callbacks'])) {
$config['callbacks'] = $this->parseCallbacks($config['callbacks']);
}
}
... | php | public function parseConfig(array $configs)
{
foreach ($configs as &$config) {
$config['states'] = $this->parseStates($config['states']);
if (isset($config['callbacks'])) {
$config['callbacks'] = $this->parseCallbacks($config['callbacks']);
}
}
... | [
"public",
"function",
"parseConfig",
"(",
"array",
"$",
"configs",
")",
"{",
"foreach",
"(",
"$",
"configs",
"as",
"&",
"$",
"config",
")",
"{",
"$",
"config",
"[",
"'states'",
"]",
"=",
"$",
"this",
"->",
"parseStates",
"(",
"$",
"config",
"[",
"'st... | Does whatever is needed to transform the config in an acceptable argument for the factory
@param array $configs
@return array | [
"Does",
"whatever",
"is",
"needed",
"to",
"transform",
"the",
"config",
"in",
"an",
"acceptable",
"argument",
"for",
"the",
"factory"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/DependencyInjection/winzouStateMachineExtension.php#L43-L54 |
winzou/StateMachineBundle | DependencyInjection/winzouStateMachineExtension.php | winzouStateMachineExtension.parseStates | protected function parseStates(array $states)
{
$newStates = array();
foreach ($states as $key => $state) {
if (null === $state) {
$newStates[] = $key;
} elseif (self::CFG_STATE_DISABLE !== $state) {
$newStates[] = $state;
} elseif ... | php | protected function parseStates(array $states)
{
$newStates = array();
foreach ($states as $key => $state) {
if (null === $state) {
$newStates[] = $key;
} elseif (self::CFG_STATE_DISABLE !== $state) {
$newStates[] = $state;
} elseif ... | [
"protected",
"function",
"parseStates",
"(",
"array",
"$",
"states",
")",
"{",
"$",
"newStates",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"states",
"as",
"$",
"key",
"=>",
"$",
"state",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"state",
")"... | Allows the disabling of states
@param array $states
@return array | [
"Allows",
"the",
"disabling",
"of",
"states"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/DependencyInjection/winzouStateMachineExtension.php#L63-L77 |
winzou/StateMachineBundle | DependencyInjection/winzouStateMachineExtension.php | winzouStateMachineExtension.parseCallbacks | protected function parseCallbacks(array $callbacks)
{
foreach (array('before', 'after') as $position) {
// Remove disabled callbacks
foreach ($callbacks[$position] as $i => $callback) {
if ($callback['disabled']) {
unset($callbacks[$position][$i]);... | php | protected function parseCallbacks(array $callbacks)
{
foreach (array('before', 'after') as $position) {
// Remove disabled callbacks
foreach ($callbacks[$position] as $i => $callback) {
if ($callback['disabled']) {
unset($callbacks[$position][$i]);... | [
"protected",
"function",
"parseCallbacks",
"(",
"array",
"$",
"callbacks",
")",
"{",
"foreach",
"(",
"array",
"(",
"'before'",
",",
"'after'",
")",
"as",
"$",
"position",
")",
"{",
"// Remove disabled callbacks",
"foreach",
"(",
"$",
"callbacks",
"[",
"$",
"... | Allows the disabling of callbacks
@param array $callbacks
@return array | [
"Allows",
"the",
"disabling",
"of",
"callbacks"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/DependencyInjection/winzouStateMachineExtension.php#L86-L106 |
winzou/StateMachineBundle | Callback/ContainerAwareCallbackFactory.php | ContainerAwareCallbackFactory.get | public function get(array $specs)
{
if (!isset($specs['do'])) {
throw new SMException(sprintf(
'CallbackFactory::get needs the index "do" to be able to build a callback, array %s given.',
json_encode($specs)
));
}
$class = $this->class;... | php | public function get(array $specs)
{
if (!isset($specs['do'])) {
throw new SMException(sprintf(
'CallbackFactory::get needs the index "do" to be able to build a callback, array %s given.',
json_encode($specs)
));
}
$class = $this->class;... | [
"public",
"function",
"get",
"(",
"array",
"$",
"specs",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"specs",
"[",
"'do'",
"]",
")",
")",
"{",
"throw",
"new",
"SMException",
"(",
"sprintf",
"(",
"'CallbackFactory::get needs the index \"do\" to be able to buil... | {@inheritDoc} | [
"{"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/Callback/ContainerAwareCallbackFactory.php#L35-L46 |
winzou/StateMachineBundle | Command/winzouStateMachineDebugCommand.php | winzouStateMachineDebugCommand.initialize | protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->config = $this->getContainer()->getParameter('sm.configs');
if (empty($this->config)) {
throw new \RuntimeException('There is no state machine configured.');
}
} | php | protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->config = $this->getContainer()->getParameter('sm.configs');
if (empty($this->config)) {
throw new \RuntimeException('There is no state machine configured.');
}
} | [
"protected",
"function",
"initialize",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'sm.configs'",
")",
";",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/Command/winzouStateMachineDebugCommand.php#L36-L43 |
winzou/StateMachineBundle | Command/winzouStateMachineDebugCommand.php | winzouStateMachineDebugCommand.interact | protected function interact(InputInterface $input, OutputInterface $output)
{
if (null !== $input->getArgument('key')) {
return;
}
$choices = array_map(function ($name, $config) {
return $name . "\t(" . $config['class'] . ' - ' . $config['graph'] . ')';
}, ar... | php | protected function interact(InputInterface $input, OutputInterface $output)
{
if (null !== $input->getArgument('key')) {
return;
}
$choices = array_map(function ($name, $config) {
return $name . "\t(" . $config['class'] . ' - ' . $config['graph'] . ')';
}, ar... | [
"protected",
"function",
"interact",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"input",
"->",
"getArgument",
"(",
"'key'",
")",
")",
"{",
"return",
";",
"}",
"$",
"choices",
"=",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/Command/winzouStateMachineDebugCommand.php#L48-L71 |
winzou/StateMachineBundle | Command/winzouStateMachineDebugCommand.php | winzouStateMachineDebugCommand.execute | public function execute(InputInterface $input, OutputInterface $output)
{
$key = $input->getArgument('key');
if (!array_key_exists($key, $this->config)) {
throw new \RuntimeException("The provided state machine key is not configured.");
}
$config = $this->config[$key];
... | php | public function execute(InputInterface $input, OutputInterface $output)
{
$key = $input->getArgument('key');
if (!array_key_exists($key, $this->config)) {
throw new \RuntimeException("The provided state machine key is not configured.");
}
$config = $this->config[$key];
... | [
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"key",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'key'",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/winzou/StateMachineBundle/blob/c90d4960016bea3cf7759ee7cfe5eca47ae84506/Command/winzouStateMachineDebugCommand.php#L76-L92 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.createChildInstance | protected function createChildInstance()
{
$instance = new static(...\func_get_args());
if (isset($this->document)) {
$instance->setDomDocument($this->document);
}
if (isset($this->root_instance)) {
$instance->root_instance = $this->root_instance;
} ... | php | protected function createChildInstance()
{
$instance = new static(...\func_get_args());
if (isset($this->document)) {
$instance->setDomDocument($this->document);
}
if (isset($this->root_instance)) {
$instance->root_instance = $this->root_instance;
} ... | [
"protected",
"function",
"createChildInstance",
"(",
")",
"{",
"$",
"instance",
"=",
"new",
"static",
"(",
"...",
"\\",
"func_get_args",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
")",
"{",
"$",
"instance",
"->",
... | Create new instance of self with some properties of its parents
@return static | [
"Create",
"new",
"instance",
"of",
"self",
"with",
"some",
"properties",
"of",
"its",
"parents"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L140-L163 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.xpath | public function xpath(string $xpath_query)
{
$result = $this->createChildInstance();
if (isset($this->document)) {
$result->xpath_query = $xpath_query;
if (isset($this->root_instance) || isset($this->xpath_query)) { // all nodes as context
foreach ($this->n... | php | public function xpath(string $xpath_query)
{
$result = $this->createChildInstance();
if (isset($this->document)) {
$result->xpath_query = $xpath_query;
if (isset($this->root_instance) || isset($this->xpath_query)) { // all nodes as context
foreach ($this->n... | [
"public",
"function",
"xpath",
"(",
"string",
"$",
"xpath_query",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
")",
"{",
"$",
"result",
"->",
"xpat... | Use xpath and return new DomQuery with resulting nodes
@param string $xpath_query
@return static | [
"Use",
"xpath",
"and",
"return",
"new",
"DomQuery",
"with",
"resulting",
"nodes"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L172-L193 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.setDomDocument | public function setDomDocument(\DOMDocument $document)
{
if (isset($this->document) && $this->document !== $document) {
throw new \Exception('Other DOMDocument already set!');
}
$this->document = $document;
} | php | public function setDomDocument(\DOMDocument $document)
{
if (isset($this->document) && $this->document !== $document) {
throw new \Exception('Other DOMDocument already set!');
}
$this->document = $document;
} | [
"public",
"function",
"setDomDocument",
"(",
"\\",
"DOMDocument",
"$",
"document",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"document",
"!==",
"$",
"document",
")",
"{",
"throw",
"new",
"\\",
"Exce... | Set dom document
@param \DOMDocument $document
@return void
@throws \Exception if other document is already set | [
"Set",
"dom",
"document"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L228-L235 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.loadDomNodeList | public function loadDomNodeList(\DOMNodeList $dom_node_list)
{
if (!isset($this->document) && $dom_node_list->length === 0) {
throw new \Exception('DOMDocument is missing!');
}
if ($dom_node_list->length > 0) {
$this->setDomDocument($dom_node_list->item(0)->ownerDocu... | php | public function loadDomNodeList(\DOMNodeList $dom_node_list)
{
if (!isset($this->document) && $dom_node_list->length === 0) {
throw new \Exception('DOMDocument is missing!');
}
if ($dom_node_list->length > 0) {
$this->setDomDocument($dom_node_list->item(0)->ownerDocu... | [
"public",
"function",
"loadDomNodeList",
"(",
"\\",
"DOMNodeList",
"$",
"dom_node_list",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"dom_node_list",
"->",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"\\",
... | Add nodes from dom node list to result set
@param \DOMNodeList $dom_node_list
@return void
@throws \Exception if no document is set and list is empty | [
"Add",
"nodes",
"from",
"dom",
"node",
"list",
"to",
"result",
"set"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L245-L258 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.addDomNode | public function addDomNode(\DOMNode $dom_node, $prepend=false)
{
if ($prepend) {
array_unshift($this->nodes, $dom_node);
} else {
$this->nodes[] = $dom_node;
}
$this->length = \count($this->nodes);
$this->setDomDocument($dom_node->ownerDocument);
... | php | public function addDomNode(\DOMNode $dom_node, $prepend=false)
{
if ($prepend) {
array_unshift($this->nodes, $dom_node);
} else {
$this->nodes[] = $dom_node;
}
$this->length = \count($this->nodes);
$this->setDomDocument($dom_node->ownerDocument);
... | [
"public",
"function",
"addDomNode",
"(",
"\\",
"DOMNode",
"$",
"dom_node",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"nodes",
",",
"$",
"dom_node",
")",
";",
"}",
"else"... | Add node to result set
@param \DOMNode $dom_node
@param bool $prepend
@return void | [
"Add",
"node",
"to",
"result",
"set"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L268-L278 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.loadContent | public function loadContent(string $content, $encoding='UTF-8')
{
$this->preserve_no_newlines = (strpos($content, '<') !== false && strpos($content, "\n") === false);
if (!\is_bool($this->xml_mode)) {
$this->xml_mode = (stripos($content, '<?xml') === 0);
}
$this->xml_pr... | php | public function loadContent(string $content, $encoding='UTF-8')
{
$this->preserve_no_newlines = (strpos($content, '<') !== false && strpos($content, "\n") === false);
if (!\is_bool($this->xml_mode)) {
$this->xml_mode = (stripos($content, '<?xml') === 0);
}
$this->xml_pr... | [
"public",
"function",
"loadContent",
"(",
"string",
"$",
"content",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"$",
"this",
"->",
"preserve_no_newlines",
"=",
"(",
"strpos",
"(",
"$",
"content",
",",
"'<'",
")",
"!==",
"false",
"&&",
"strpos",
"(",
... | Load html or xml content
@param string $content
@param string $encoding
@return void | [
"Load",
"html",
"or",
"xml",
"content"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L288-L334 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.get | public function get($index)
{
$result = \array_slice($this->nodes, $index, 1); // note: index can be negative
if (\count($result) > 0) {
return $result[0];
}
return null; // return null if no result for key
} | php | public function get($index)
{
$result = \array_slice($this->nodes, $index, 1); // note: index can be negative
if (\count($result) > 0) {
return $result[0];
}
return null; // return null if no result for key
} | [
"public",
"function",
"get",
"(",
"$",
"index",
")",
"{",
"$",
"result",
"=",
"\\",
"array_slice",
"(",
"$",
"this",
"->",
"nodes",
",",
"$",
"index",
",",
"1",
")",
";",
"// note: index can be negative",
"if",
"(",
"\\",
"count",
"(",
"$",
"result",
... | Grants access to the DOM nodes of this instance
@param int $index
@return \DOMNode|null | [
"Grants",
"access",
"to",
"the",
"DOM",
"nodes",
"of",
"this",
"instance"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L343-L351 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.find | public function find($selector)
{
if (\is_string($selector)) {
$css_expression = $selector;
} else {
$selector_tag_names = array();
$selector_result = self::create($selector);
foreach ($selector_result as $node) {
$selector_tag_names[] ... | php | public function find($selector)
{
if (\is_string($selector)) {
$css_expression = $selector;
} else {
$selector_tag_names = array();
$selector_result = self::create($selector);
foreach ($selector_result as $node) {
$selector_tag_names[] ... | [
"public",
"function",
"find",
"(",
"$",
"selector",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"selector",
")",
")",
"{",
"$",
"css_expression",
"=",
"$",
"selector",
";",
"}",
"else",
"{",
"$",
"selector_tag_names",
"=",
"array",
"(",
")",
";... | Get the descendants of each element in the current set of matched elements, filtered by a selector
@param string|static|\DOMNodeList|\DOMNode $selector A string containing a selector expression,
or DomQuery|DOMNodeList|DOMNode instance to match against
@return static | [
"Get",
"the",
"descendants",
"of",
"each",
"element",
"in",
"the",
"current",
"set",
"of",
"matched",
"elements",
"filtered",
"by",
"a",
"selector"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L361-L395 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getNextElement | protected static function getNextElement(\DOMNode $node)
{
while ($node && ($node = $node->nextSibling)) {
if ($node instanceof \DOMElement) {
break;
}
}
return $node;
} | php | protected static function getNextElement(\DOMNode $node)
{
while ($node && ($node = $node->nextSibling)) {
if ($node instanceof \DOMElement) {
break;
}
}
return $node;
} | [
"protected",
"static",
"function",
"getNextElement",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"while",
"(",
"$",
"node",
"&&",
"(",
"$",
"node",
"=",
"$",
"node",
"->",
"nextSibling",
")",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DO... | Get next element from node
@param \DOMNode $node
@return \DOMNode | [
"Get",
"next",
"element",
"from",
"node"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L404-L413 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getPreviousElement | protected static function getPreviousElement(\DOMNode $node)
{
while ($node && ($node = $node->previousSibling)) {
if ($node instanceof \DOMElement) {
break;
}
}
return $node;
} | php | protected static function getPreviousElement(\DOMNode $node)
{
while ($node && ($node = $node->previousSibling)) {
if ($node instanceof \DOMElement) {
break;
}
}
return $node;
} | [
"protected",
"static",
"function",
"getPreviousElement",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"while",
"(",
"$",
"node",
"&&",
"(",
"$",
"node",
"=",
"$",
"node",
"->",
"previousSibling",
")",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\... | Get next element from node
@param \DOMNode $node
@return \DOMNode | [
"Get",
"next",
"element",
"from",
"node"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L422-L431 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.findOrFail | public function findOrFail($selector)
{
$result = $this->find($selector);
if ($result->length === 0) {
if (\is_string($selector)) {
throw new \Exception('Find with selector "'.$selector.'" failed!');
}
throw new \Exception('Find with node (collecti... | php | public function findOrFail($selector)
{
$result = $this->find($selector);
if ($result->length === 0) {
if (\is_string($selector)) {
throw new \Exception('Find with selector "'.$selector.'" failed!');
}
throw new \Exception('Find with node (collecti... | [
"public",
"function",
"findOrFail",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"selector",
")",
";",
"if",
"(",
"$",
"result",
"->",
"length",
"===",
"0",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
... | Get the descendants of each element in the current set of matched elements, filtered by a selector.
If no results are found a exception is thrown.
@param string|static|\DOMNodeList|\DOMNode $selector A string containing a selector expression,
or DomQuery|DOMNodeList|DOMNode instance to match against
@return static
@t... | [
"Get",
"the",
"descendants",
"of",
"each",
"element",
"in",
"the",
"current",
"set",
"of",
"matched",
"elements",
"filtered",
"by",
"a",
"selector",
".",
"If",
"no",
"results",
"are",
"found",
"a",
"exception",
"is",
"thrown",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L453-L463 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.each | public function each(callable $callback)
{
foreach ($this->nodes as $index => $node) {
$return_value = \call_user_func($callback, $node, $index);
if ($return_value === false) {
break;
}
}
return $this;
} | php | public function each(callable $callback)
{
foreach ($this->nodes as $index => $node) {
$return_value = \call_user_func($callback, $node, $index);
if ($return_value === false) {
break;
}
}
return $this;
} | [
"public",
"function",
"each",
"(",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"index",
"=>",
"$",
"node",
")",
"{",
"$",
"return_value",
"=",
"\\",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"... | Iterate over result set and executing a callback for each node
@param callable $callback
@return $this | [
"Iterate",
"over",
"result",
"set",
"and",
"executing",
"a",
"callback",
"for",
"each",
"node"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L472-L483 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.map | public function map(callable $callback)
{
$result = array();
foreach ($this->nodes as $index => $node) {
$return_value = \call_user_func($callback, $node, $index);
if ($return_value === null) {
continue;
} elseif (\is_array($return_value)) {
... | php | public function map(callable $callback)
{
$result = array();
foreach ($this->nodes as $index => $node) {
$return_value = \call_user_func($callback, $node, $index);
if ($return_value === null) {
continue;
} elseif (\is_array($return_value)) {
... | [
"public",
"function",
"map",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"index",
"=>",
"$",
"node",
")",
"{",
"$",
"return_value",
"=",
"\\",
"call_... | Pass each element in the current matched set through a function,
producing an array containing the return values
@param callable $callback
@return array | [
"Pass",
"each",
"element",
"in",
"the",
"current",
"matched",
"set",
"through",
"a",
"function",
"producing",
"an",
"array",
"containing",
"the",
"return",
"values"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L493-L510 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.