repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolReader.php | ProtocolReader.consumeDecimalValue | public function consumeDecimalValue(Buffer $buffer)
{
$scale = $buffer->consumeUint8();
$value = $buffer->consumeUint32();
return $value * pow(10, $scale);
} | php | public function consumeDecimalValue(Buffer $buffer)
{
$scale = $buffer->consumeUint8();
$value = $buffer->consumeUint32();
return $value * pow(10, $scale);
} | [
"public",
"function",
"consumeDecimalValue",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"scale",
"=",
"$",
"buffer",
"->",
"consumeUint8",
"(",
")",
";",
"$",
"value",
"=",
"$",
"buffer",
"->",
"consumeUint32",
"(",
")",
";",
"return",
"$",
"value",
... | Consumes AMQP decimal value.
@param Buffer $buffer
@return int | [
"Consumes",
"AMQP",
"decimal",
"value",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolReader.php#L220-L225 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolWriterGenerated.php | ProtocolWriterGenerated.appendProtocolHeader | public function appendProtocolHeader(Buffer $buffer)
{
$buffer->append('AMQP');
$buffer->appendUint8(0);
$buffer->appendUint8(0);
$buffer->appendUint8(9);
$buffer->appendUint8(1);
} | php | public function appendProtocolHeader(Buffer $buffer)
{
$buffer->append('AMQP');
$buffer->appendUint8(0);
$buffer->appendUint8(0);
$buffer->appendUint8(9);
$buffer->appendUint8(1);
} | [
"public",
"function",
"appendProtocolHeader",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"buffer",
"->",
"append",
"(",
"'AMQP'",
")",
";",
"$",
"buffer",
"->",
"appendUint8",
"(",
"0",
")",
";",
"$",
"buffer",
"->",
"appendUint8",
"(",
"0",
")",
";"... | Appends AMQP protocol header to buffer.
@param Buffer $buffer | [
"Appends",
"AMQP",
"protocol",
"header",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolWriterGenerated.php#L38-L45 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.swapEndian64 | public static function swapEndian64($s)
{
return $s[7] . $s[6] . $s[5] . $s[4] . $s[3] . $s[2] . $s[1] . $s[0];
} | php | public static function swapEndian64($s)
{
return $s[7] . $s[6] . $s[5] . $s[4] . $s[3] . $s[2] . $s[1] . $s[0];
} | [
"public",
"static",
"function",
"swapEndian64",
"(",
"$",
"s",
")",
"{",
"return",
"$",
"s",
"[",
"7",
"]",
".",
"$",
"s",
"[",
"6",
"]",
".",
"$",
"s",
"[",
"5",
"]",
".",
"$",
"s",
"[",
"4",
"]",
".",
"$",
"s",
"[",
"3",
"]",
".",
"$"... | Swaps 64-bit integer endianness.
@param string $s
@return string | [
"Swaps",
"64",
"-",
"bit",
"integer",
"endianness",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L99-L102 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.append | public function append($s)
{
if ($s instanceof Buffer) {
$s = $s->buffer;
}
$this->buffer .= $s;
$this->length = strlen($this->buffer);
return $this;
} | php | public function append($s)
{
if ($s instanceof Buffer) {
$s = $s->buffer;
}
$this->buffer .= $s;
$this->length = strlen($this->buffer);
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"s",
")",
"{",
"if",
"(",
"$",
"s",
"instanceof",
"Buffer",
")",
"{",
"$",
"s",
"=",
"$",
"s",
"->",
"buffer",
";",
"}",
"$",
"this",
"->",
"buffer",
".=",
"$",
"s",
";",
"$",
"this",
"->",
"length",
... | Appends bytes at the end of the buffer.
@param string $s
@return self | [
"Appends",
"bytes",
"at",
"the",
"end",
"of",
"the",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L253-L261 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.readUint16 | public function readUint16($offset = 0)
{
$s = $this->read(2, $offset);
list(, $ret) = unpack("n", $s);
return $ret;
} | php | public function readUint16($offset = 0)
{
$s = $this->read(2, $offset);
list(, $ret) = unpack("n", $s);
return $ret;
} | [
"public",
"function",
"readUint16",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"read",
"(",
"2",
",",
"$",
"offset",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"n\"",
",",
"$",
"s",
")",
... | Reads unsigned 16-bit integer from buffer.
@param int $offset
@return int | [
"Reads",
"unsigned",
"16",
"-",
"bit",
"integer",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L338-L343 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.readInt16 | public function readInt16($offset = 0)
{
$s = $this->read(2, $offset);
list(, $ret) = unpack("s", self::$isLittleEndian ? self::swapEndian16($s) : $s);
return $ret;
} | php | public function readInt16($offset = 0)
{
$s = $this->read(2, $offset);
list(, $ret) = unpack("s", self::$isLittleEndian ? self::swapEndian16($s) : $s);
return $ret;
} | [
"public",
"function",
"readInt16",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"read",
"(",
"2",
",",
"$",
"offset",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"s\"",
",",
"self",
"::",
"$... | Reads signed 16-bit integer from buffer.
@param int $offset
@return int | [
"Reads",
"signed",
"16",
"-",
"bit",
"integer",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L351-L356 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.consumeInt16 | public function consumeInt16()
{
$s = $this->consume(2);
list(, $ret) = unpack("s", self::$isLittleEndian ? self::swapEndian16($s) : $s);
return $ret;
} | php | public function consumeInt16()
{
$s = $this->consume(2);
list(, $ret) = unpack("s", self::$isLittleEndian ? self::swapEndian16($s) : $s);
return $ret;
} | [
"public",
"function",
"consumeInt16",
"(",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"consume",
"(",
"2",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"s\"",
",",
"self",
"::",
"$",
"isLittleEndian",
"?",
"self",
"::",
"sw... | Reads and discards signed 16-bit integer from buffer.
@return int | [
"Reads",
"and",
"discards",
"signed",
"16",
"-",
"bit",
"integer",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L375-L380 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.appendInt16 | public function appendInt16($value)
{
$s = pack("s", $value);
return $this->append(self::$isLittleEndian ? self::swapEndian16($s) : $s);
} | php | public function appendInt16($value)
{
$s = pack("s", $value);
return $this->append(self::$isLittleEndian ? self::swapEndian16($s) : $s);
} | [
"public",
"function",
"appendInt16",
"(",
"$",
"value",
")",
"{",
"$",
"s",
"=",
"pack",
"(",
"\"s\"",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"append",
"(",
"self",
"::",
"$",
"isLittleEndian",
"?",
"self",
"::",
"swapEndian16",
"(... | Appends signed 16-bit integer to buffer.
@param int $value
@return Buffer | [
"Appends",
"signed",
"16",
"-",
"bit",
"integer",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L400-L404 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.readUint32 | public function readUint32($offset = 0)
{
$s = $this->read(4, $offset);
list(, $ret) = unpack("N", $s);
return $ret;
} | php | public function readUint32($offset = 0)
{
$s = $this->read(4, $offset);
list(, $ret) = unpack("N", $s);
return $ret;
} | [
"public",
"function",
"readUint32",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"read",
"(",
"4",
",",
"$",
"offset",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"N\"",
",",
"$",
"s",
")",
... | Reads unsigned 32-bit integer from buffer.
@param int $offset
@return int | [
"Reads",
"unsigned",
"32",
"-",
"bit",
"integer",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L412-L417 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.appendInt32 | public function appendInt32($value)
{
$s = pack("l", $value);
return $this->append(self::$isLittleEndian ? self::swapEndian32($s) : $s);
} | php | public function appendInt32($value)
{
$s = pack("l", $value);
return $this->append(self::$isLittleEndian ? self::swapEndian32($s) : $s);
} | [
"public",
"function",
"appendInt32",
"(",
"$",
"value",
")",
"{",
"$",
"s",
"=",
"pack",
"(",
"\"l\"",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"append",
"(",
"self",
"::",
"$",
"isLittleEndian",
"?",
"self",
"::",
"swapEndian32",
"(... | Appends signed 32-bit integer to buffer.
@param int $value
@return Buffer | [
"Appends",
"signed",
"32",
"-",
"bit",
"integer",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L474-L478 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.readUint64 | public function readUint64($offset = 0)
{
$s = $this->read(8, $offset);
if (self::$native64BitPack) {
list(, $ret) = unpack("Q", self::$isLittleEndian ? self::swapEndian64($s) : $s);
} else {
$d = unpack("Lh/Ll", self::$isLittleEndian ? self::swapHalvedEndian64($s) : $s);
$ret = $d["h"] << 32 | $d["l"];
}
return $ret;
} | php | public function readUint64($offset = 0)
{
$s = $this->read(8, $offset);
if (self::$native64BitPack) {
list(, $ret) = unpack("Q", self::$isLittleEndian ? self::swapEndian64($s) : $s);
} else {
$d = unpack("Lh/Ll", self::$isLittleEndian ? self::swapHalvedEndian64($s) : $s);
$ret = $d["h"] << 32 | $d["l"];
}
return $ret;
} | [
"public",
"function",
"readUint64",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"read",
"(",
"8",
",",
"$",
"offset",
")",
";",
"if",
"(",
"self",
"::",
"$",
"native64BitPack",
")",
"{",
"list",
"(",
",",
"$",
"ret... | Reads unsigned 64-bit integer from buffer.
@param int $offset
@return int | [
"Reads",
"unsigned",
"64",
"-",
"bit",
"integer",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L486-L496 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.consumeUint64 | public function consumeUint64()
{
$s = $this->consume(8);
if (self::$native64BitPack) {
list(, $ret) = unpack("Q", self::$isLittleEndian ? self::swapEndian64($s) : $s);
} else {
$d = unpack("Lh/Ll", self::$isLittleEndian ? self::swapHalvedEndian64($s) : $s);
$ret = $d["h"] << 32 | $d["l"];
}
return $ret;
} | php | public function consumeUint64()
{
$s = $this->consume(8);
if (self::$native64BitPack) {
list(, $ret) = unpack("Q", self::$isLittleEndian ? self::swapEndian64($s) : $s);
} else {
$d = unpack("Lh/Ll", self::$isLittleEndian ? self::swapHalvedEndian64($s) : $s);
$ret = $d["h"] << 32 | $d["l"];
}
return $ret;
} | [
"public",
"function",
"consumeUint64",
"(",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"consume",
"(",
"8",
")",
";",
"if",
"(",
"self",
"::",
"$",
"native64BitPack",
")",
"{",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"Q\"",
",",... | Reads and discards unsigned 64-bit integer from buffer.
@return int | [
"Reads",
"and",
"discards",
"unsigned",
"64",
"-",
"bit",
"integer",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L521-L531 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.appendUint64 | public function appendUint64($value)
{
if (self::$native64BitPack) {
$s = pack("Q", $value);
if (self::$isLittleEndian) {
$s = self::swapEndian64($s);
}
} else {
$s = pack("LL", ($value & 0xffffffff00000000) >> 32, $value & 0x00000000ffffffff);
if (self::$isLittleEndian) {
$s = self::swapHalvedEndian64($s);
}
}
return $this->append($s);
} | php | public function appendUint64($value)
{
if (self::$native64BitPack) {
$s = pack("Q", $value);
if (self::$isLittleEndian) {
$s = self::swapEndian64($s);
}
} else {
$s = pack("LL", ($value & 0xffffffff00000000) >> 32, $value & 0x00000000ffffffff);
if (self::$isLittleEndian) {
$s = self::swapHalvedEndian64($s);
}
}
return $this->append($s);
} | [
"public",
"function",
"appendUint64",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"native64BitPack",
")",
"{",
"$",
"s",
"=",
"pack",
"(",
"\"Q\"",
",",
"$",
"value",
")",
";",
"if",
"(",
"self",
"::",
"$",
"isLittleEndian",
")",
"{"... | Appends unsigned 64-bit integer to buffer.
@param int $value
@return Buffer | [
"Appends",
"unsigned",
"64",
"-",
"bit",
"integer",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L556-L571 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.readFloat | public function readFloat($offset = 0)
{
$s = $this->read(4, $offset);
list(, $ret) = unpack("f", self::$isLittleEndian ? self::swapEndian32($s) : $s);
return $ret;
} | php | public function readFloat($offset = 0)
{
$s = $this->read(4, $offset);
list(, $ret) = unpack("f", self::$isLittleEndian ? self::swapEndian32($s) : $s);
return $ret;
} | [
"public",
"function",
"readFloat",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"read",
"(",
"4",
",",
"$",
"offset",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"f\"",
",",
"self",
"::",
"$... | Reads float from buffer.
@param int $offset
@return float | [
"Reads",
"float",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L602-L607 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.consumeFloat | public function consumeFloat()
{
$s = $this->consume(4);
list(, $ret) = unpack("f", self::$isLittleEndian ? self::swapEndian32($s) : $s);
return $ret;
} | php | public function consumeFloat()
{
$s = $this->consume(4);
list(, $ret) = unpack("f", self::$isLittleEndian ? self::swapEndian32($s) : $s);
return $ret;
} | [
"public",
"function",
"consumeFloat",
"(",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"consume",
"(",
"4",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"f\"",
",",
"self",
"::",
"$",
"isLittleEndian",
"?",
"self",
"::",
"sw... | Reads and discards float from buffer.
@return float | [
"Reads",
"and",
"discards",
"float",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L614-L619 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.readDouble | public function readDouble($offset = 0)
{
$s = $this->read(8, $offset);
list(, $ret) = unpack("d", self::$isLittleEndian ? self::swapEndian64($s) : $s);
return $ret;
} | php | public function readDouble($offset = 0)
{
$s = $this->read(8, $offset);
list(, $ret) = unpack("d", self::$isLittleEndian ? self::swapEndian64($s) : $s);
return $ret;
} | [
"public",
"function",
"readDouble",
"(",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"read",
"(",
"8",
",",
"$",
"offset",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"d\"",
",",
"self",
"::",
"... | Reads double from buffer.
@param int $offset
@return float | [
"Reads",
"double",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L639-L644 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.consumeDouble | public function consumeDouble()
{
$s = $this->consume(8);
list(, $ret) = unpack("d", self::$isLittleEndian ? self::swapEndian64($s) : $s);
return $ret;
} | php | public function consumeDouble()
{
$s = $this->consume(8);
list(, $ret) = unpack("d", self::$isLittleEndian ? self::swapEndian64($s) : $s);
return $ret;
} | [
"public",
"function",
"consumeDouble",
"(",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"consume",
"(",
"8",
")",
";",
"list",
"(",
",",
"$",
"ret",
")",
"=",
"unpack",
"(",
"\"d\"",
",",
"self",
"::",
"$",
"isLittleEndian",
"?",
"self",
"::",
"s... | Reads and discards double from buffer.
@return float | [
"Reads",
"and",
"discards",
"double",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L651-L656 | train |
jakubkulhan/bunny | src/Bunny/Protocol/Buffer.php | Buffer.appendDouble | public function appendDouble($value)
{
$s = pack("d", $value);
return $this->append(self::$isLittleEndian ? self::swapEndian64($s) : $s);
} | php | public function appendDouble($value)
{
$s = pack("d", $value);
return $this->append(self::$isLittleEndian ? self::swapEndian64($s) : $s);
} | [
"public",
"function",
"appendDouble",
"(",
"$",
"value",
")",
"{",
"$",
"s",
"=",
"pack",
"(",
"\"d\"",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"append",
"(",
"self",
"::",
"$",
"isLittleEndian",
"?",
"self",
"::",
"swapEndian64",
"... | Appends double to buffer.
@param float $value
@return Buffer | [
"Appends",
"double",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/Buffer.php#L664-L668 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.removeReturnListener | public function removeReturnListener(callable $callback)
{
foreach ($this->returnCallbacks as $k => $v) {
if ($v === $callback) {
unset($this->returnCallbacks[$k]);
}
}
return $this;
} | php | public function removeReturnListener(callable $callback)
{
foreach ($this->returnCallbacks as $k => $v) {
if ($v === $callback) {
unset($this->returnCallbacks[$k]);
}
}
return $this;
} | [
"public",
"function",
"removeReturnListener",
"(",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"returnCallbacks",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"$",
"callback",
")",
"{",
"unset",
... | Removes registered return listener. If the callback is not registered, this is noop.
@param callable $callback
@return $this | [
"Removes",
"registered",
"return",
"listener",
".",
"If",
"the",
"callback",
"is",
"not",
"registered",
"this",
"is",
"noop",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L160-L169 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.addAckListener | public function addAckListener(callable $callback)
{
if ($this->mode !== ChannelModeEnum::CONFIRM) {
throw new ChannelException("Ack/nack listener can be added when channel in confirm mode.");
}
$this->removeAckListener($callback);
$this->ackCallbacks[] = $callback;
return $this;
} | php | public function addAckListener(callable $callback)
{
if ($this->mode !== ChannelModeEnum::CONFIRM) {
throw new ChannelException("Ack/nack listener can be added when channel in confirm mode.");
}
$this->removeAckListener($callback);
$this->ackCallbacks[] = $callback;
return $this;
} | [
"public",
"function",
"addAckListener",
"(",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
"!==",
"ChannelModeEnum",
"::",
"CONFIRM",
")",
"{",
"throw",
"new",
"ChannelException",
"(",
"\"Ack/nack listener can be added when channel in ... | Listener is called whenever 'basic.ack' or 'basic.nack' is received.
@param callable $callback
@return $this | [
"Listener",
"is",
"called",
"whenever",
"basic",
".",
"ack",
"or",
"basic",
".",
"nack",
"is",
"received",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L177-L186 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.close | public function close($replyCode = 0, $replyText = "")
{
if ($this->state === ChannelStateEnum::CLOSED) {
throw new ChannelException("Trying to close already closed channel #{$this->channelId}.");
}
if ($this->state === ChannelStateEnum::CLOSING) {
return $this->closePromise;
}
$this->state = ChannelStateEnum::CLOSING;
$this->client->channelClose($this->channelId, $replyCode, $replyText, 0, 0);
$this->closeDeferred = new Deferred();
return $this->closePromise = $this->closeDeferred->promise()->then(function () {
$this->client->removeChannel($this->channelId);
});
} | php | public function close($replyCode = 0, $replyText = "")
{
if ($this->state === ChannelStateEnum::CLOSED) {
throw new ChannelException("Trying to close already closed channel #{$this->channelId}.");
}
if ($this->state === ChannelStateEnum::CLOSING) {
return $this->closePromise;
}
$this->state = ChannelStateEnum::CLOSING;
$this->client->channelClose($this->channelId, $replyCode, $replyText, 0, 0);
$this->closeDeferred = new Deferred();
return $this->closePromise = $this->closeDeferred->promise()->then(function () {
$this->client->removeChannel($this->channelId);
});
} | [
"public",
"function",
"close",
"(",
"$",
"replyCode",
"=",
"0",
",",
"$",
"replyText",
"=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"ChannelStateEnum",
"::",
"CLOSED",
")",
"{",
"throw",
"new",
"ChannelException",
"(",
"\"Trying t... | Closes channel.
Always returns a promise, because there can be outstanding messages to be processed.
@param int $replyCode
@param string $replyText
@return PromiseInterface | [
"Closes",
"channel",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L218-L235 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.consume | public function consume(callable $callback, $queue = "", $consumerTag = "", $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
{
$response = $this->consumeImpl($queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
if ($response instanceof MethodBasicConsumeOkFrame) {
$this->deliverCallbacks[$response->consumerTag] = $callback;
return $response;
} elseif ($response instanceof PromiseInterface) {
return $response->then(function (MethodBasicConsumeOkFrame $response) use ($callback) {
$this->deliverCallbacks[$response->consumerTag] = $callback;
return $response;
});
} else {
throw new ChannelException(
"basic.consume unexpected response of type " . gettype($response) .
(is_object($response) ? " (" . get_class($response) . ")" : "") .
"."
);
}
} | php | public function consume(callable $callback, $queue = "", $consumerTag = "", $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
{
$response = $this->consumeImpl($queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
if ($response instanceof MethodBasicConsumeOkFrame) {
$this->deliverCallbacks[$response->consumerTag] = $callback;
return $response;
} elseif ($response instanceof PromiseInterface) {
return $response->then(function (MethodBasicConsumeOkFrame $response) use ($callback) {
$this->deliverCallbacks[$response->consumerTag] = $callback;
return $response;
});
} else {
throw new ChannelException(
"basic.consume unexpected response of type " . gettype($response) .
(is_object($response) ? " (" . get_class($response) . ")" : "") .
"."
);
}
} | [
"public",
"function",
"consume",
"(",
"callable",
"$",
"callback",
",",
"$",
"queue",
"=",
"\"\"",
",",
"$",
"consumerTag",
"=",
"\"\"",
",",
"$",
"noLocal",
"=",
"false",
",",
"$",
"noAck",
"=",
"false",
",",
"$",
"exclusive",
"=",
"false",
",",
"$"... | Creates new consumer on channel.
@param callable $callback
@param string $queue
@param string $consumerTag
@param bool $noLocal
@param bool $noAck
@param bool $exclusive
@param bool $nowait
@param array $arguments
@return MethodBasicConsumeOkFrame|PromiseInterface | [
"Creates",
"new",
"consumer",
"on",
"channel",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L250-L271 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.run | public function run(callable $callback, $queue = "", $consumerTag = "", $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
{
$response = $this->consume($callback, $queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
if ($response instanceof MethodBasicConsumeOkFrame) {
$this->client->run();
} elseif ($response instanceof PromiseInterface) {
$response->done(function () {
$this->client->run();
});
} else {
throw new ChannelException(
"Unexpected response of type " . gettype($response) .
(is_object($response) ? " (" . get_class($response) . ")" : "") .
"."
);
}
} | php | public function run(callable $callback, $queue = "", $consumerTag = "", $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
{
$response = $this->consume($callback, $queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
if ($response instanceof MethodBasicConsumeOkFrame) {
$this->client->run();
} elseif ($response instanceof PromiseInterface) {
$response->done(function () {
$this->client->run();
});
} else {
throw new ChannelException(
"Unexpected response of type " . gettype($response) .
(is_object($response) ? " (" . get_class($response) . ")" : "") .
"."
);
}
} | [
"public",
"function",
"run",
"(",
"callable",
"$",
"callback",
",",
"$",
"queue",
"=",
"\"\"",
",",
"$",
"consumerTag",
"=",
"\"\"",
",",
"$",
"noLocal",
"=",
"false",
",",
"$",
"noAck",
"=",
"false",
",",
"$",
"exclusive",
"=",
"false",
",",
"$",
... | Convenience method that registers consumer and then starts client event loop.
@param callable $callback
@param string $queue
@param string $consumerTag
@param bool $noLocal
@param bool $noAck
@param bool $exclusive
@param bool $nowait
@param array $arguments | [
"Convenience",
"method",
"that",
"registers",
"consumer",
"and",
"then",
"starts",
"client",
"event",
"loop",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L285-L304 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.ack | public function ack(Message $message, $multiple = false)
{
return $this->ackImpl($message->deliveryTag, $multiple);
} | php | public function ack(Message $message, $multiple = false)
{
return $this->ackImpl($message->deliveryTag, $multiple);
} | [
"public",
"function",
"ack",
"(",
"Message",
"$",
"message",
",",
"$",
"multiple",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"ackImpl",
"(",
"$",
"message",
"->",
"deliveryTag",
",",
"$",
"multiple",
")",
";",
"}"
] | Acks given message.
@param Message $message
@param boolean $multiple
@return boolean|PromiseInterface | [
"Acks",
"given",
"message",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L313-L316 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.nack | public function nack(Message $message, $multiple = false, $requeue = true)
{
return $this->nackImpl($message->deliveryTag, $multiple, $requeue);
} | php | public function nack(Message $message, $multiple = false, $requeue = true)
{
return $this->nackImpl($message->deliveryTag, $multiple, $requeue);
} | [
"public",
"function",
"nack",
"(",
"Message",
"$",
"message",
",",
"$",
"multiple",
"=",
"false",
",",
"$",
"requeue",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"nackImpl",
"(",
"$",
"message",
"->",
"deliveryTag",
",",
"$",
"multiple",
",",
... | Nacks given message.
@param Message $message
@param boolean $multiple
@param boolean $requeue
@return boolean|PromiseInterface | [
"Nacks",
"given",
"message",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L326-L329 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.reject | public function reject(Message $message, $requeue = true)
{
return $this->rejectImpl($message->deliveryTag, $requeue);
} | php | public function reject(Message $message, $requeue = true)
{
return $this->rejectImpl($message->deliveryTag, $requeue);
} | [
"public",
"function",
"reject",
"(",
"Message",
"$",
"message",
",",
"$",
"requeue",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"rejectImpl",
"(",
"$",
"message",
"->",
"deliveryTag",
",",
"$",
"requeue",
")",
";",
"}"
] | Rejects given message.
@param Message $message
@param bool $requeue
@return boolean|PromiseInterface | [
"Rejects",
"given",
"message",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L338-L341 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.get | public function get($queue = "", $noAck = false)
{
if ($this->getDeferred !== null) {
throw new ChannelException("Another 'basic.get' already in progress. You should use 'basic.consume' instead of multiple 'basic.get'.");
}
$response = $this->getImpl($queue, $noAck);
if ($response instanceof PromiseInterface) {
$this->getDeferred = new Deferred();
$response->done(function ($frame) {
if ($frame instanceof MethodBasicGetEmptyFrame) {
// deferred has to be first nullified and then resolved, otherwise results in race condition
$deferred = $this->getDeferred;
$this->getDeferred = null;
$deferred->resolve(null);
} elseif ($frame instanceof MethodBasicGetOkFrame) {
$this->getOkFrame = $frame;
$this->state = ChannelStateEnum::AWAITING_HEADER;
} else {
throw new \LogicException("This statement should never be reached.");
}
});
return $this->getDeferred->promise();
} elseif ($response instanceof MethodBasicGetEmptyFrame) {
return null;
} elseif ($response instanceof MethodBasicGetOkFrame) {
$this->state = ChannelStateEnum::AWAITING_HEADER;
$headerFrame = $this->getClient()->awaitContentHeader($this->getChannelId());
$this->headerFrame = $headerFrame;
$this->bodySizeRemaining = $headerFrame->bodySize;
$this->state = ChannelStateEnum::AWAITING_BODY;
while ($this->bodySizeRemaining > 0) {
$bodyFrame = $this->getClient()->awaitContentBody($this->getChannelId());
$this->bodyBuffer->append($bodyFrame->payload);
$this->bodySizeRemaining -= $bodyFrame->payloadSize;
if ($this->bodySizeRemaining < 0) {
$this->state = ChannelStateEnum::ERROR;
$this->client->disconnect(Constants::STATUS_SYNTAX_ERROR, $errorMessage = "Body overflow, received " . (-$this->bodySizeRemaining) . " more bytes.");
throw new ChannelException($errorMessage);
}
}
$this->state = ChannelStateEnum::READY;
$message = new Message(
null,
$response->deliveryTag,
$response->redelivered,
$response->exchange,
$response->routingKey,
$this->headerFrame->toArray(),
$this->bodyBuffer->consume($this->bodyBuffer->getLength())
);
$this->headerFrame = null;
return $message;
} else {
throw new \LogicException("This statement should never be reached.");
}
} | php | public function get($queue = "", $noAck = false)
{
if ($this->getDeferred !== null) {
throw new ChannelException("Another 'basic.get' already in progress. You should use 'basic.consume' instead of multiple 'basic.get'.");
}
$response = $this->getImpl($queue, $noAck);
if ($response instanceof PromiseInterface) {
$this->getDeferred = new Deferred();
$response->done(function ($frame) {
if ($frame instanceof MethodBasicGetEmptyFrame) {
// deferred has to be first nullified and then resolved, otherwise results in race condition
$deferred = $this->getDeferred;
$this->getDeferred = null;
$deferred->resolve(null);
} elseif ($frame instanceof MethodBasicGetOkFrame) {
$this->getOkFrame = $frame;
$this->state = ChannelStateEnum::AWAITING_HEADER;
} else {
throw new \LogicException("This statement should never be reached.");
}
});
return $this->getDeferred->promise();
} elseif ($response instanceof MethodBasicGetEmptyFrame) {
return null;
} elseif ($response instanceof MethodBasicGetOkFrame) {
$this->state = ChannelStateEnum::AWAITING_HEADER;
$headerFrame = $this->getClient()->awaitContentHeader($this->getChannelId());
$this->headerFrame = $headerFrame;
$this->bodySizeRemaining = $headerFrame->bodySize;
$this->state = ChannelStateEnum::AWAITING_BODY;
while ($this->bodySizeRemaining > 0) {
$bodyFrame = $this->getClient()->awaitContentBody($this->getChannelId());
$this->bodyBuffer->append($bodyFrame->payload);
$this->bodySizeRemaining -= $bodyFrame->payloadSize;
if ($this->bodySizeRemaining < 0) {
$this->state = ChannelStateEnum::ERROR;
$this->client->disconnect(Constants::STATUS_SYNTAX_ERROR, $errorMessage = "Body overflow, received " . (-$this->bodySizeRemaining) . " more bytes.");
throw new ChannelException($errorMessage);
}
}
$this->state = ChannelStateEnum::READY;
$message = new Message(
null,
$response->deliveryTag,
$response->redelivered,
$response->exchange,
$response->routingKey,
$this->headerFrame->toArray(),
$this->bodyBuffer->consume($this->bodyBuffer->getLength())
);
$this->headerFrame = null;
return $message;
} else {
throw new \LogicException("This statement should never be reached.");
}
} | [
"public",
"function",
"get",
"(",
"$",
"queue",
"=",
"\"\"",
",",
"$",
"noAck",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDeferred",
"!==",
"null",
")",
"{",
"throw",
"new",
"ChannelException",
"(",
"\"Another 'basic.get' already in progress.... | Synchronously returns message if there is any waiting in the queue.
@param string $queue
@param bool $noAck
@return Message|PromiseInterface | [
"Synchronously",
"returns",
"message",
"if",
"there",
"is",
"any",
"waiting",
"in",
"the",
"queue",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L350-L422 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.publish | public function publish($body, array $headers = [], $exchange = '', $routingKey = '', $mandatory = false, $immediate = false)
{
$response = $this->publishImpl($body, $headers, $exchange, $routingKey, $mandatory, $immediate);
if ($this->mode === ChannelModeEnum::CONFIRM) {
if ($response instanceof PromiseInterface) {
return $response->then(function () {
return ++$this->deliveryTag;
});
} else {
return ++$this->deliveryTag;
}
} else {
return $response;
}
} | php | public function publish($body, array $headers = [], $exchange = '', $routingKey = '', $mandatory = false, $immediate = false)
{
$response = $this->publishImpl($body, $headers, $exchange, $routingKey, $mandatory, $immediate);
if ($this->mode === ChannelModeEnum::CONFIRM) {
if ($response instanceof PromiseInterface) {
return $response->then(function () {
return ++$this->deliveryTag;
});
} else {
return ++$this->deliveryTag;
}
} else {
return $response;
}
} | [
"public",
"function",
"publish",
"(",
"$",
"body",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"exchange",
"=",
"''",
",",
"$",
"routingKey",
"=",
"''",
",",
"$",
"mandatory",
"=",
"false",
",",
"$",
"immediate",
"=",
"false",
")",
"{",
... | Published message to given exchange.
@param string $body
@param array $headers
@param string $exchange
@param string $routingKey
@param bool $mandatory
@param bool $immediate
@return bool|PromiseInterface|int | [
"Published",
"message",
"to",
"given",
"exchange",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L435-L450 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.cancel | public function cancel($consumerTag, $nowait = false)
{
$response = $this->cancelImpl($consumerTag, $nowait);
unset($this->deliverCallbacks[$consumerTag]);
return $response;
} | php | public function cancel($consumerTag, $nowait = false)
{
$response = $this->cancelImpl($consumerTag, $nowait);
unset($this->deliverCallbacks[$consumerTag]);
return $response;
} | [
"public",
"function",
"cancel",
"(",
"$",
"consumerTag",
",",
"$",
"nowait",
"=",
"false",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"cancelImpl",
"(",
"$",
"consumerTag",
",",
"$",
"nowait",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"deliv... | Cancels given consumer subscription.
@param string $consumerTag
@param bool $nowait
@return bool|Protocol\MethodBasicCancelOkFrame|PromiseInterface | [
"Cancels",
"given",
"consumer",
"subscription",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L459-L464 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.confirmSelect | public function confirmSelect(callable $callback = null, $nowait = false)
{
if ($this->mode !== ChannelModeEnum::REGULAR) {
throw new ChannelException("Channel not in regular mode, cannot change to transactional mode.");
}
$response = $this->confirmSelectImpl($nowait);
if ($response instanceof PromiseInterface) {
return $response->then(function ($response) use ($callback) {
$this->enterConfirmMode($callback);
return $response;
});
} else {
$this->enterConfirmMode($callback);
return $response;
}
} | php | public function confirmSelect(callable $callback = null, $nowait = false)
{
if ($this->mode !== ChannelModeEnum::REGULAR) {
throw new ChannelException("Channel not in regular mode, cannot change to transactional mode.");
}
$response = $this->confirmSelectImpl($nowait);
if ($response instanceof PromiseInterface) {
return $response->then(function ($response) use ($callback) {
$this->enterConfirmMode($callback);
return $response;
});
} else {
$this->enterConfirmMode($callback);
return $response;
}
} | [
"public",
"function",
"confirmSelect",
"(",
"callable",
"$",
"callback",
"=",
"null",
",",
"$",
"nowait",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
"!==",
"ChannelModeEnum",
"::",
"REGULAR",
")",
"{",
"throw",
"new",
"ChannelException",... | Changes channel to confirm mode. Broker then asynchronously sends 'basic.ack's for published messages.
@param bool $nowait
@return Protocol\MethodConfirmSelectOkFrame|PromiseInterface | [
"Changes",
"channel",
"to",
"confirm",
"mode",
".",
"Broker",
"then",
"asynchronously",
"sends",
"basic",
".",
"ack",
"s",
"for",
"published",
"messages",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L525-L543 | train |
jakubkulhan/bunny | src/Bunny/Channel.php | Channel.onBodyComplete | protected function onBodyComplete()
{
if ($this->returnFrame) {
$content = $this->bodyBuffer->consume($this->bodyBuffer->getLength());
$message = new Message(
null,
null,
false,
$this->returnFrame->exchange,
$this->returnFrame->routingKey,
$this->headerFrame->toArray(),
$content
);
foreach ($this->returnCallbacks as $callback) {
$callback($message, $this->returnFrame);
}
$this->returnFrame = null;
$this->headerFrame = null;
} elseif ($this->deliverFrame) {
$content = $this->bodyBuffer->consume($this->bodyBuffer->getLength());
if (isset($this->deliverCallbacks[$this->deliverFrame->consumerTag])) {
$message = new Message(
$this->deliverFrame->consumerTag,
$this->deliverFrame->deliveryTag,
$this->deliverFrame->redelivered,
$this->deliverFrame->exchange,
$this->deliverFrame->routingKey,
$this->headerFrame->toArray(),
$content
);
$callback = $this->deliverCallbacks[$this->deliverFrame->consumerTag];
$callback($message, $this, $this->client);
}
$this->deliverFrame = null;
$this->headerFrame = null;
} elseif ($this->getOkFrame) {
$content = $this->bodyBuffer->consume($this->bodyBuffer->getLength());
// deferred has to be first nullified and then resolved, otherwise results in race condition
$deferred = $this->getDeferred;
$this->getDeferred = null;
$deferred->resolve(new Message(
null,
$this->getOkFrame->deliveryTag,
$this->getOkFrame->redelivered,
$this->getOkFrame->exchange,
$this->getOkFrame->routingKey,
$this->headerFrame->toArray(),
$content
));
$this->getOkFrame = null;
$this->headerFrame = null;
} else {
throw new \LogicException("Either return or deliver frame has to be handled here.");
}
} | php | protected function onBodyComplete()
{
if ($this->returnFrame) {
$content = $this->bodyBuffer->consume($this->bodyBuffer->getLength());
$message = new Message(
null,
null,
false,
$this->returnFrame->exchange,
$this->returnFrame->routingKey,
$this->headerFrame->toArray(),
$content
);
foreach ($this->returnCallbacks as $callback) {
$callback($message, $this->returnFrame);
}
$this->returnFrame = null;
$this->headerFrame = null;
} elseif ($this->deliverFrame) {
$content = $this->bodyBuffer->consume($this->bodyBuffer->getLength());
if (isset($this->deliverCallbacks[$this->deliverFrame->consumerTag])) {
$message = new Message(
$this->deliverFrame->consumerTag,
$this->deliverFrame->deliveryTag,
$this->deliverFrame->redelivered,
$this->deliverFrame->exchange,
$this->deliverFrame->routingKey,
$this->headerFrame->toArray(),
$content
);
$callback = $this->deliverCallbacks[$this->deliverFrame->consumerTag];
$callback($message, $this, $this->client);
}
$this->deliverFrame = null;
$this->headerFrame = null;
} elseif ($this->getOkFrame) {
$content = $this->bodyBuffer->consume($this->bodyBuffer->getLength());
// deferred has to be first nullified and then resolved, otherwise results in race condition
$deferred = $this->getDeferred;
$this->getDeferred = null;
$deferred->resolve(new Message(
null,
$this->getOkFrame->deliveryTag,
$this->getOkFrame->redelivered,
$this->getOkFrame->exchange,
$this->getOkFrame->routingKey,
$this->headerFrame->toArray(),
$content
));
$this->getOkFrame = null;
$this->headerFrame = null;
} else {
throw new \LogicException("Either return or deliver frame has to be handled here.");
}
} | [
"protected",
"function",
"onBodyComplete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"returnFrame",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"bodyBuffer",
"->",
"consume",
"(",
"$",
"this",
"->",
"bodyBuffer",
"->",
"getLength",
"(",
")",
"... | Callback after content body has been completely received. | [
"Callback",
"after",
"content",
"body",
"has",
"been",
"completely",
"received",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Channel.php#L704-L768 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.exchangeDeclare | public function exchangeDeclare($exchange, $exchangeType = 'direct', $passive = false, $durable = false, $autoDelete = false, $internal = false, $nowait = false, $arguments = [])
{
return $this->getClient()->exchangeDeclare($this->getChannelId(), $exchange, $exchangeType, $passive, $durable, $autoDelete, $internal, $nowait, $arguments);
} | php | public function exchangeDeclare($exchange, $exchangeType = 'direct', $passive = false, $durable = false, $autoDelete = false, $internal = false, $nowait = false, $arguments = [])
{
return $this->getClient()->exchangeDeclare($this->getChannelId(), $exchange, $exchangeType, $passive, $durable, $autoDelete, $internal, $nowait, $arguments);
} | [
"public",
"function",
"exchangeDeclare",
"(",
"$",
"exchange",
",",
"$",
"exchangeType",
"=",
"'direct'",
",",
"$",
"passive",
"=",
"false",
",",
"$",
"durable",
"=",
"false",
",",
"$",
"autoDelete",
"=",
"false",
",",
"$",
"internal",
"=",
"false",
",",... | Calls exchange.declare AMQP method.
@param string $exchange
@param string $exchangeType
@param boolean $passive
@param boolean $durable
@param boolean $autoDelete
@param boolean $internal
@param boolean $nowait
@param array $arguments
@return boolean|Promise\PromiseInterface|Protocol\MethodExchangeDeclareOkFrame | [
"Calls",
"exchange",
".",
"declare",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L45-L48 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.exchangeDelete | public function exchangeDelete($exchange, $ifUnused = false, $nowait = false)
{
return $this->getClient()->exchangeDelete($this->getChannelId(), $exchange, $ifUnused, $nowait);
} | php | public function exchangeDelete($exchange, $ifUnused = false, $nowait = false)
{
return $this->getClient()->exchangeDelete($this->getChannelId(), $exchange, $ifUnused, $nowait);
} | [
"public",
"function",
"exchangeDelete",
"(",
"$",
"exchange",
",",
"$",
"ifUnused",
"=",
"false",
",",
"$",
"nowait",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"exchangeDelete",
"(",
"$",
"this",
"->",
"getChannelI... | Calls exchange.delete AMQP method.
@param string $exchange
@param boolean $ifUnused
@param boolean $nowait
@return boolean|Promise\PromiseInterface|Protocol\MethodExchangeDeleteOkFrame | [
"Calls",
"exchange",
".",
"delete",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L59-L62 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.exchangeBind | public function exchangeBind($destination, $source, $routingKey = '', $nowait = false, $arguments = [])
{
return $this->getClient()->exchangeBind($this->getChannelId(), $destination, $source, $routingKey, $nowait, $arguments);
} | php | public function exchangeBind($destination, $source, $routingKey = '', $nowait = false, $arguments = [])
{
return $this->getClient()->exchangeBind($this->getChannelId(), $destination, $source, $routingKey, $nowait, $arguments);
} | [
"public",
"function",
"exchangeBind",
"(",
"$",
"destination",
",",
"$",
"source",
",",
"$",
"routingKey",
"=",
"''",
",",
"$",
"nowait",
"=",
"false",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")"... | Calls exchange.bind AMQP method.
@param string $destination
@param string $source
@param string $routingKey
@param boolean $nowait
@param array $arguments
@return boolean|Promise\PromiseInterface|Protocol\MethodExchangeBindOkFrame | [
"Calls",
"exchange",
".",
"bind",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L75-L78 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.queueDeclare | public function queueDeclare($queue = '', $passive = false, $durable = false, $exclusive = false, $autoDelete = false, $nowait = false, $arguments = [])
{
return $this->getClient()->queueDeclare($this->getChannelId(), $queue, $passive, $durable, $exclusive, $autoDelete, $nowait, $arguments);
} | php | public function queueDeclare($queue = '', $passive = false, $durable = false, $exclusive = false, $autoDelete = false, $nowait = false, $arguments = [])
{
return $this->getClient()->queueDeclare($this->getChannelId(), $queue, $passive, $durable, $exclusive, $autoDelete, $nowait, $arguments);
} | [
"public",
"function",
"queueDeclare",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"passive",
"=",
"false",
",",
"$",
"durable",
"=",
"false",
",",
"$",
"exclusive",
"=",
"false",
",",
"$",
"autoDelete",
"=",
"false",
",",
"$",
"nowait",
"=",
"false",
","... | Calls queue.declare AMQP method.
@param string $queue
@param boolean $passive
@param boolean $durable
@param boolean $exclusive
@param boolean $autoDelete
@param boolean $nowait
@param array $arguments
@return boolean|Promise\PromiseInterface|Protocol\MethodQueueDeclareOkFrame | [
"Calls",
"queue",
".",
"declare",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L109-L112 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.queueBind | public function queueBind($queue = '', $exchange, $routingKey = '', $nowait = false, $arguments = [])
{
return $this->getClient()->queueBind($this->getChannelId(), $queue, $exchange, $routingKey, $nowait, $arguments);
} | php | public function queueBind($queue = '', $exchange, $routingKey = '', $nowait = false, $arguments = [])
{
return $this->getClient()->queueBind($this->getChannelId(), $queue, $exchange, $routingKey, $nowait, $arguments);
} | [
"public",
"function",
"queueBind",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"exchange",
",",
"$",
"routingKey",
"=",
"''",
",",
"$",
"nowait",
"=",
"false",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(... | Calls queue.bind AMQP method.
@param string $queue
@param string $exchange
@param string $routingKey
@param boolean $nowait
@param array $arguments
@return boolean|Promise\PromiseInterface|Protocol\MethodQueueBindOkFrame | [
"Calls",
"queue",
".",
"bind",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L125-L128 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.queuePurge | public function queuePurge($queue = '', $nowait = false)
{
return $this->getClient()->queuePurge($this->getChannelId(), $queue, $nowait);
} | php | public function queuePurge($queue = '', $nowait = false)
{
return $this->getClient()->queuePurge($this->getChannelId(), $queue, $nowait);
} | [
"public",
"function",
"queuePurge",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"nowait",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"queuePurge",
"(",
"$",
"this",
"->",
"getChannelId",
"(",
")",
",",
"$",
"queue",... | Calls queue.purge AMQP method.
@param string $queue
@param boolean $nowait
@return boolean|Promise\PromiseInterface|Protocol\MethodQueuePurgeOkFrame | [
"Calls",
"queue",
".",
"purge",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L138-L141 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.queueDelete | public function queueDelete($queue = '', $ifUnused = false, $ifEmpty = false, $nowait = false)
{
return $this->getClient()->queueDelete($this->getChannelId(), $queue, $ifUnused, $ifEmpty, $nowait);
} | php | public function queueDelete($queue = '', $ifUnused = false, $ifEmpty = false, $nowait = false)
{
return $this->getClient()->queueDelete($this->getChannelId(), $queue, $ifUnused, $ifEmpty, $nowait);
} | [
"public",
"function",
"queueDelete",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"ifUnused",
"=",
"false",
",",
"$",
"ifEmpty",
"=",
"false",
",",
"$",
"nowait",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"queueDele... | Calls queue.delete AMQP method.
@param string $queue
@param boolean $ifUnused
@param boolean $ifEmpty
@param boolean $nowait
@return boolean|Promise\PromiseInterface|Protocol\MethodQueueDeleteOkFrame | [
"Calls",
"queue",
".",
"delete",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L153-L156 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.queueUnbind | public function queueUnbind($queue = '', $exchange, $routingKey = '', $arguments = [])
{
return $this->getClient()->queueUnbind($this->getChannelId(), $queue, $exchange, $routingKey, $arguments);
} | php | public function queueUnbind($queue = '', $exchange, $routingKey = '', $arguments = [])
{
return $this->getClient()->queueUnbind($this->getChannelId(), $queue, $exchange, $routingKey, $arguments);
} | [
"public",
"function",
"queueUnbind",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"exchange",
",",
"$",
"routingKey",
"=",
"''",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"queueUnbind",
"(",
... | Calls queue.unbind AMQP method.
@param string $queue
@param string $exchange
@param string $routingKey
@param array $arguments
@return boolean|Promise\PromiseInterface|Protocol\MethodQueueUnbindOkFrame | [
"Calls",
"queue",
".",
"unbind",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L168-L171 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.qos | public function qos($prefetchSize = 0, $prefetchCount = 0, $global = false)
{
return $this->getClient()->qos($this->getChannelId(), $prefetchSize, $prefetchCount, $global);
} | php | public function qos($prefetchSize = 0, $prefetchCount = 0, $global = false)
{
return $this->getClient()->qos($this->getChannelId(), $prefetchSize, $prefetchCount, $global);
} | [
"public",
"function",
"qos",
"(",
"$",
"prefetchSize",
"=",
"0",
",",
"$",
"prefetchCount",
"=",
"0",
",",
"$",
"global",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"qos",
"(",
"$",
"this",
"->",
"getChannelId",... | Calls basic.qos AMQP method.
@param int $prefetchSize
@param int $prefetchCount
@param boolean $global
@return boolean|Promise\PromiseInterface|Protocol\MethodBasicQosOkFrame | [
"Calls",
"basic",
".",
"qos",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L182-L185 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.consume | public function consume($queue = '', $consumerTag = '', $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
{
return $this->getClient()->consume($this->getChannelId(), $queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
} | php | public function consume($queue = '', $consumerTag = '', $noLocal = false, $noAck = false, $exclusive = false, $nowait = false, $arguments = [])
{
return $this->getClient()->consume($this->getChannelId(), $queue, $consumerTag, $noLocal, $noAck, $exclusive, $nowait, $arguments);
} | [
"public",
"function",
"consume",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"consumerTag",
"=",
"''",
",",
"$",
"noLocal",
"=",
"false",
",",
"$",
"noAck",
"=",
"false",
",",
"$",
"exclusive",
"=",
"false",
",",
"$",
"nowait",
"=",
"false",
",",
"$",
... | Calls basic.consume AMQP method.
@param string $queue
@param string $consumerTag
@param boolean $noLocal
@param boolean $noAck
@param boolean $exclusive
@param boolean $nowait
@param array $arguments
@return boolean|Promise\PromiseInterface|Protocol\MethodBasicConsumeOkFrame | [
"Calls",
"basic",
".",
"consume",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L200-L203 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.cancel | public function cancel($consumerTag, $nowait = false)
{
return $this->getClient()->cancel($this->getChannelId(), $consumerTag, $nowait);
} | php | public function cancel($consumerTag, $nowait = false)
{
return $this->getClient()->cancel($this->getChannelId(), $consumerTag, $nowait);
} | [
"public",
"function",
"cancel",
"(",
"$",
"consumerTag",
",",
"$",
"nowait",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"cancel",
"(",
"$",
"this",
"->",
"getChannelId",
"(",
")",
",",
"$",
"consumerTag",
",",
"... | Calls basic.cancel AMQP method.
@param string $consumerTag
@param boolean $nowait
@return boolean|Promise\PromiseInterface|Protocol\MethodBasicCancelOkFrame | [
"Calls",
"basic",
".",
"cancel",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L213-L216 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.publish | public function publish($body, array $headers = [], $exchange = '', $routingKey = '', $mandatory = false, $immediate = false)
{
return $this->getClient()->publish($this->getChannelId(), $body, $headers, $exchange, $routingKey, $mandatory, $immediate);
} | php | public function publish($body, array $headers = [], $exchange = '', $routingKey = '', $mandatory = false, $immediate = false)
{
return $this->getClient()->publish($this->getChannelId(), $body, $headers, $exchange, $routingKey, $mandatory, $immediate);
} | [
"public",
"function",
"publish",
"(",
"$",
"body",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"exchange",
"=",
"''",
",",
"$",
"routingKey",
"=",
"''",
",",
"$",
"mandatory",
"=",
"false",
",",
"$",
"immediate",
"=",
"false",
")",
"{",
... | Calls basic.publish AMQP method.
@param string $body
@param array $headers
@param string $exchange
@param string $routingKey
@param boolean $mandatory
@param boolean $immediate
@return boolean|Promise\PromiseInterface | [
"Calls",
"basic",
".",
"publish",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L230-L233 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.get | public function get($queue = '', $noAck = false)
{
return $this->getClient()->get($this->getChannelId(), $queue, $noAck);
} | php | public function get($queue = '', $noAck = false)
{
return $this->getClient()->get($this->getChannelId(), $queue, $noAck);
} | [
"public",
"function",
"get",
"(",
"$",
"queue",
"=",
"''",
",",
"$",
"noAck",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getChannelId",
"(",
")",
",",
"$",
"queue",
",",
"$",
... | Calls basic.get AMQP method.
@param string $queue
@param boolean $noAck
@return boolean|Promise\PromiseInterface|Protocol\MethodBasicGetOkFrame|Protocol\MethodBasicGetEmptyFrame | [
"Calls",
"basic",
".",
"get",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L243-L246 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.ack | public function ack($deliveryTag = 0, $multiple = false)
{
return $this->getClient()->ack($this->getChannelId(), $deliveryTag, $multiple);
} | php | public function ack($deliveryTag = 0, $multiple = false)
{
return $this->getClient()->ack($this->getChannelId(), $deliveryTag, $multiple);
} | [
"public",
"function",
"ack",
"(",
"$",
"deliveryTag",
"=",
"0",
",",
"$",
"multiple",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"ack",
"(",
"$",
"this",
"->",
"getChannelId",
"(",
")",
",",
"$",
"deliveryTag",
... | Calls basic.ack AMQP method.
@param int $deliveryTag
@param boolean $multiple
@return boolean|Promise\PromiseInterface | [
"Calls",
"basic",
".",
"ack",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L256-L259 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.reject | public function reject($deliveryTag, $requeue = true)
{
return $this->getClient()->reject($this->getChannelId(), $deliveryTag, $requeue);
} | php | public function reject($deliveryTag, $requeue = true)
{
return $this->getClient()->reject($this->getChannelId(), $deliveryTag, $requeue);
} | [
"public",
"function",
"reject",
"(",
"$",
"deliveryTag",
",",
"$",
"requeue",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"reject",
"(",
"$",
"this",
"->",
"getChannelId",
"(",
")",
",",
"$",
"deliveryTag",
",",
"... | Calls basic.reject AMQP method.
@param int $deliveryTag
@param boolean $requeue
@return boolean|Promise\PromiseInterface | [
"Calls",
"basic",
".",
"reject",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L269-L272 | train |
jakubkulhan/bunny | src/Bunny/ChannelMethods.php | ChannelMethods.nack | public function nack($deliveryTag = 0, $multiple = false, $requeue = true)
{
return $this->getClient()->nack($this->getChannelId(), $deliveryTag, $multiple, $requeue);
} | php | public function nack($deliveryTag = 0, $multiple = false, $requeue = true)
{
return $this->getClient()->nack($this->getChannelId(), $deliveryTag, $multiple, $requeue);
} | [
"public",
"function",
"nack",
"(",
"$",
"deliveryTag",
"=",
"0",
",",
"$",
"multiple",
"=",
"false",
",",
"$",
"requeue",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"nack",
"(",
"$",
"this",
"->",
"getChannelId",... | Calls basic.nack AMQP method.
@param int $deliveryTag
@param boolean $multiple
@param boolean $requeue
@return boolean|Promise\PromiseInterface | [
"Calls",
"basic",
".",
"nack",
"AMQP",
"method",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/ChannelMethods.php#L307-L310 | train |
jakubkulhan/bunny | src/Bunny/Async/Client.php | Client.init | protected function init()
{
parent::init();
$this->flushWriteBufferPromise = null;
$this->awaitCallbacks = [];
$this->disconnectPromise = null;
} | php | protected function init()
{
parent::init();
$this->flushWriteBufferPromise = null;
$this->awaitCallbacks = [];
$this->disconnectPromise = null;
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"flushWriteBufferPromise",
"=",
"null",
";",
"$",
"this",
"->",
"awaitCallbacks",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"disconnectPromise",
"=",
... | Initializes instance. | [
"Initializes",
"instance",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Async/Client.php#L96-L102 | train |
jakubkulhan/bunny | src/Bunny/Async/Client.php | Client.flushWriteBuffer | protected function flushWriteBuffer()
{
if ($this->flushWriteBufferPromise) {
return $this->flushWriteBufferPromise;
} else {
$deferred = new Promise\Deferred();
$this->eventLoop->addWriteStream($this->getStream(), function ($stream) use ($deferred) {
try {
$this->write();
if ($this->writeBuffer->isEmpty()) {
$this->eventLoop->removeWriteStream($stream);
$this->flushWriteBufferPromise = null;
$deferred->resolve(true);
}
} catch (\Exception $e) {
$this->eventLoop->removeWriteStream($stream);
$this->flushWriteBufferPromise = null;
$deferred->reject($e);
}
});
return $this->flushWriteBufferPromise = $deferred->promise();
}
} | php | protected function flushWriteBuffer()
{
if ($this->flushWriteBufferPromise) {
return $this->flushWriteBufferPromise;
} else {
$deferred = new Promise\Deferred();
$this->eventLoop->addWriteStream($this->getStream(), function ($stream) use ($deferred) {
try {
$this->write();
if ($this->writeBuffer->isEmpty()) {
$this->eventLoop->removeWriteStream($stream);
$this->flushWriteBufferPromise = null;
$deferred->resolve(true);
}
} catch (\Exception $e) {
$this->eventLoop->removeWriteStream($stream);
$this->flushWriteBufferPromise = null;
$deferred->reject($e);
}
});
return $this->flushWriteBufferPromise = $deferred->promise();
}
} | [
"protected",
"function",
"flushWriteBuffer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"flushWriteBufferPromise",
")",
"{",
"return",
"$",
"this",
"->",
"flushWriteBufferPromise",
";",
"}",
"else",
"{",
"$",
"deferred",
"=",
"new",
"Promise",
"\\",
"Defer... | Asynchronously sends buffered data over the wire.
- Calls {@link eventLoops}'s addWriteStream() with client's stream.
- Consecutive calls will return the same instance of promise.
@return Promise\PromiseInterface | [
"Asynchronously",
"sends",
"buffered",
"data",
"over",
"the",
"wire",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Async/Client.php#L149-L176 | train |
jakubkulhan/bunny | src/Bunny/Async/Client.php | Client.connect | public function connect()
{
if ($this->state !== ClientStateEnum::NOT_CONNECTED) {
return Promise\reject(new ClientException("Client already connected/connecting."));
}
$this->state = ClientStateEnum::CONNECTING;
$this->writer->appendProtocolHeader($this->writeBuffer);
try {
$this->eventLoop->addReadStream($this->getStream(), [$this, "onDataAvailable"]);
} catch (\Exception $e) {
return Promise\reject($e);
}
return $this->flushWriteBuffer()->then(function () {
return $this->awaitConnectionStart();
})->then(function (MethodConnectionStartFrame $start) {
return $this->authResponse($start);
})->then(function () {
return $this->awaitConnectionTune();
})->then(function (MethodConnectionTuneFrame $tune) {
$this->frameMax = $tune->frameMax;
if ($tune->channelMax > 0) {
$this->channelMax = $tune->channelMax;
}
return $this->connectionTuneOk($tune->channelMax, $tune->frameMax, $this->options["heartbeat"]);
})->then(function () {
return $this->connectionOpen($this->options["vhost"]);
})->then(function () {
$this->heartbeatTimer = $this->eventLoop->addTimer($this->options["heartbeat"], [$this, "onHeartbeat"]);
$this->state = ClientStateEnum::CONNECTED;
return $this;
});
} | php | public function connect()
{
if ($this->state !== ClientStateEnum::NOT_CONNECTED) {
return Promise\reject(new ClientException("Client already connected/connecting."));
}
$this->state = ClientStateEnum::CONNECTING;
$this->writer->appendProtocolHeader($this->writeBuffer);
try {
$this->eventLoop->addReadStream($this->getStream(), [$this, "onDataAvailable"]);
} catch (\Exception $e) {
return Promise\reject($e);
}
return $this->flushWriteBuffer()->then(function () {
return $this->awaitConnectionStart();
})->then(function (MethodConnectionStartFrame $start) {
return $this->authResponse($start);
})->then(function () {
return $this->awaitConnectionTune();
})->then(function (MethodConnectionTuneFrame $tune) {
$this->frameMax = $tune->frameMax;
if ($tune->channelMax > 0) {
$this->channelMax = $tune->channelMax;
}
return $this->connectionTuneOk($tune->channelMax, $tune->frameMax, $this->options["heartbeat"]);
})->then(function () {
return $this->connectionOpen($this->options["vhost"]);
})->then(function () {
$this->heartbeatTimer = $this->eventLoop->addTimer($this->options["heartbeat"], [$this, "onHeartbeat"]);
$this->state = ClientStateEnum::CONNECTED;
return $this;
});
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"!==",
"ClientStateEnum",
"::",
"NOT_CONNECTED",
")",
"{",
"return",
"Promise",
"\\",
"reject",
"(",
"new",
"ClientException",
"(",
"\"Client already connected/connecting.\"",
... | Connects to AMQP server.
Calling connect() multiple times will result in error.
@return Promise\PromiseInterface | [
"Connects",
"to",
"AMQP",
"server",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Async/Client.php#L185-L226 | train |
jakubkulhan/bunny | src/Bunny/Async/Client.php | Client.onHeartbeat | public function onHeartbeat()
{
$now = microtime(true);
$nextHeartbeat = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
if ($now >= $nextHeartbeat) {
$this->writer->appendFrame(new HeartbeatFrame(), $this->writeBuffer);
$this->flushWriteBuffer()->done(function () {
$this->heartbeatTimer = $this->eventLoop->addTimer($this->options["heartbeat"], [$this, "onHeartbeat"]);
});
} else {
$this->heartbeatTimer = $this->eventLoop->addTimer($nextHeartbeat - $now, [$this, "onHeartbeat"]);
}
} | php | public function onHeartbeat()
{
$now = microtime(true);
$nextHeartbeat = ($this->lastWrite ?: $now) + $this->options["heartbeat"];
if ($now >= $nextHeartbeat) {
$this->writer->appendFrame(new HeartbeatFrame(), $this->writeBuffer);
$this->flushWriteBuffer()->done(function () {
$this->heartbeatTimer = $this->eventLoop->addTimer($this->options["heartbeat"], [$this, "onHeartbeat"]);
});
} else {
$this->heartbeatTimer = $this->eventLoop->addTimer($nextHeartbeat - $now, [$this, "onHeartbeat"]);
}
} | [
"public",
"function",
"onHeartbeat",
"(",
")",
"{",
"$",
"now",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"nextHeartbeat",
"=",
"(",
"$",
"this",
"->",
"lastWrite",
"?",
":",
"$",
"now",
")",
"+",
"$",
"this",
"->",
"options",
"[",
"\"heartbeat\"... | Callback when heartbeat timer timed out. | [
"Callback",
"when",
"heartbeat",
"timer",
"timed",
"out",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Async/Client.php#L323-L337 | train |
jakubkulhan/bunny | src/Bunny/Client.php | Client.connect | public function connect()
{
if ($this->state !== ClientStateEnum::NOT_CONNECTED) {
throw new ClientException("Client already connected/connecting.");
}
try {
$this->state = ClientStateEnum::CONNECTING;
$this->writer->appendProtocolHeader($this->writeBuffer);
$this->flushWriteBuffer();
$this->authResponse($this->awaitConnectionStart());
$tune = $this->awaitConnectionTune();
$this->connectionTuneOk($tune->channelMax, $tune->frameMax, $this->options["heartbeat"]); // FIXME: options heartbeat
$this->frameMax = $tune->frameMax;
if ($tune->channelMax > 0) {
$this->channelMax = $tune->channelMax;
}
$this->connectionOpen($this->options["vhost"]);
$this->state = ClientStateEnum::CONNECTED;
return $this;
} catch (\Exception $e) {
$this->state = ClientStateEnum::ERROR;
throw $e;
}
} | php | public function connect()
{
if ($this->state !== ClientStateEnum::NOT_CONNECTED) {
throw new ClientException("Client already connected/connecting.");
}
try {
$this->state = ClientStateEnum::CONNECTING;
$this->writer->appendProtocolHeader($this->writeBuffer);
$this->flushWriteBuffer();
$this->authResponse($this->awaitConnectionStart());
$tune = $this->awaitConnectionTune();
$this->connectionTuneOk($tune->channelMax, $tune->frameMax, $this->options["heartbeat"]); // FIXME: options heartbeat
$this->frameMax = $tune->frameMax;
if ($tune->channelMax > 0) {
$this->channelMax = $tune->channelMax;
}
$this->connectionOpen($this->options["vhost"]);
$this->state = ClientStateEnum::CONNECTED;
return $this;
} catch (\Exception $e) {
$this->state = ClientStateEnum::ERROR;
throw $e;
}
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"!==",
"ClientStateEnum",
"::",
"NOT_CONNECTED",
")",
"{",
"throw",
"new",
"ClientException",
"(",
"\"Client already connected/connecting.\"",
")",
";",
"}",
"try",
"{",
"$"... | Synchronously connects to AMQP server.
@throws \Exception
@return self | [
"Synchronously",
"connects",
"to",
"AMQP",
"server",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Client.php#L98-L126 | train |
jakubkulhan/bunny | src/Bunny/Client.php | Client.disconnect | public function disconnect($replyCode = 0, $replyText = "")
{
if ($this->state === ClientStateEnum::DISCONNECTING) {
return $this->disconnectPromise;
}
if ($this->state !== ClientStateEnum::CONNECTED) {
return Promise\reject(new ClientException("Client is not connected."));
}
$this->state = ClientStateEnum::DISCONNECTING;
$promises = [];
if ($replyCode === 0) {
foreach ($this->channels as $channel) {
$promises[] = $channel->close();
}
}
return $this->disconnectPromise = Promise\all($promises)->then(function () use ($replyCode, $replyText) {
if (!empty($this->channels)) {
throw new \LogicException("All channels have to be closed by now.");
}
$this->connectionClose($replyCode, $replyText, 0, 0);
$this->closeStream();
$this->init();
return $this;
});
} | php | public function disconnect($replyCode = 0, $replyText = "")
{
if ($this->state === ClientStateEnum::DISCONNECTING) {
return $this->disconnectPromise;
}
if ($this->state !== ClientStateEnum::CONNECTED) {
return Promise\reject(new ClientException("Client is not connected."));
}
$this->state = ClientStateEnum::DISCONNECTING;
$promises = [];
if ($replyCode === 0) {
foreach ($this->channels as $channel) {
$promises[] = $channel->close();
}
}
return $this->disconnectPromise = Promise\all($promises)->then(function () use ($replyCode, $replyText) {
if (!empty($this->channels)) {
throw new \LogicException("All channels have to be closed by now.");
}
$this->connectionClose($replyCode, $replyText, 0, 0);
$this->closeStream();
$this->init();
return $this;
});
} | [
"public",
"function",
"disconnect",
"(",
"$",
"replyCode",
"=",
"0",
",",
"$",
"replyText",
"=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"ClientStateEnum",
"::",
"DISCONNECTING",
")",
"{",
"return",
"$",
"this",
"->",
"disconnectP... | Disconnects from AMQP server.
@param int $replyCode
@param string $replyText
@return Promise\PromiseInterface | [
"Disconnects",
"from",
"AMQP",
"server",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Client.php#L135-L165 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolWriter.php | ProtocolWriter.appendTable | public function appendTable(array $table, Buffer $originalBuffer)
{
$buffer = new Buffer();
foreach ($table as $k => $v) {
$buffer->appendUint8(strlen($k));
$buffer->append($k);
$this->appendFieldValue($v, $buffer);
}
$originalBuffer->appendUint32($buffer->getLength());
$originalBuffer->append($buffer);
} | php | public function appendTable(array $table, Buffer $originalBuffer)
{
$buffer = new Buffer();
foreach ($table as $k => $v) {
$buffer->appendUint8(strlen($k));
$buffer->append($k);
$this->appendFieldValue($v, $buffer);
}
$originalBuffer->appendUint32($buffer->getLength());
$originalBuffer->append($buffer);
} | [
"public",
"function",
"appendTable",
"(",
"array",
"$",
"table",
",",
"Buffer",
"$",
"originalBuffer",
")",
"{",
"$",
"buffer",
"=",
"new",
"Buffer",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"buffe... | Appends AMQP table to buffer.
@param array $table
@param Buffer $originalBuffer | [
"Appends",
"AMQP",
"table",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolWriter.php#L140-L152 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolWriter.php | ProtocolWriter.appendArray | public function appendArray(array $value, Buffer $originalBuffer)
{
$buffer = new Buffer();
foreach ($value as $v) {
$this->appendFieldValue($v, $buffer);
}
$originalBuffer->appendUint32($buffer->getLength());
$originalBuffer->append($buffer);
} | php | public function appendArray(array $value, Buffer $originalBuffer)
{
$buffer = new Buffer();
foreach ($value as $v) {
$this->appendFieldValue($v, $buffer);
}
$originalBuffer->appendUint32($buffer->getLength());
$originalBuffer->append($buffer);
} | [
"public",
"function",
"appendArray",
"(",
"array",
"$",
"value",
",",
"Buffer",
"$",
"originalBuffer",
")",
"{",
"$",
"buffer",
"=",
"new",
"Buffer",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"appendFie... | Appends AMQP array to buffer.
@param array $value
@param Buffer $originalBuffer | [
"Appends",
"AMQP",
"array",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolWriter.php#L160-L170 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolWriter.php | ProtocolWriter.appendBits | public function appendBits(array $bits, Buffer $buffer)
{
$value = 0;
foreach ($bits as $n => $bit) {
$bit = $bit ? 1 : 0;
$value |= $bit << $n;
}
$buffer->appendUint8($value);
} | php | public function appendBits(array $bits, Buffer $buffer)
{
$value = 0;
foreach ($bits as $n => $bit) {
$bit = $bit ? 1 : 0;
$value |= $bit << $n;
}
$buffer->appendUint8($value);
} | [
"public",
"function",
"appendBits",
"(",
"array",
"$",
"bits",
",",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"value",
"=",
"0",
";",
"foreach",
"(",
"$",
"bits",
"as",
"$",
"n",
"=>",
"$",
"bit",
")",
"{",
"$",
"bit",
"=",
"$",
"bit",
"?",
"1",
... | Appends packed bits to buffer.
@param array $bits
@param Buffer $buffer | [
"Appends",
"packed",
"bits",
"to",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolWriter.php#L189-L197 | train |
slince/shopify-api-php | src/Common/Manager/AbstractManager.php | AbstractManager.fromArray | public function fromArray(array $data, $modelClass = null)
{
if (null === $modelClass) {
$modelClass = $this->getModelClass();
}
return $this->client->getHydrator()->hydrate($modelClass, $data);
} | php | public function fromArray(array $data, $modelClass = null)
{
if (null === $modelClass) {
$modelClass = $this->getModelClass();
}
return $this->client->getHydrator()->hydrate($modelClass, $data);
} | [
"public",
"function",
"fromArray",
"(",
"array",
"$",
"data",
",",
"$",
"modelClass",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"modelClass",
")",
"{",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"getModelClass",
"(",
")",
";",
"}",
"retur... | Create the model from an array.
@param array $data
@param string $modelClass
@return ModelInterface | [
"Create",
"the",
"model",
"from",
"an",
"array",
"."
] | 7ff12b22cec4f118740cb1a7896508998d1cf96f | https://github.com/slince/shopify-api-php/blob/7ff12b22cec4f118740cb1a7896508998d1cf96f/src/Common/Manager/AbstractManager.php#L51-L58 | train |
slince/shopify-api-php | src/Common/Manager/AbstractManager.php | AbstractManager.createMany | public function createMany(array $data, $modelClass = null)
{
$models = [];
foreach ($data as $item) {
$models[] = $this->fromArray($item, $modelClass);
}
return $models;
} | php | public function createMany(array $data, $modelClass = null)
{
$models = [];
foreach ($data as $item) {
$models[] = $this->fromArray($item, $modelClass);
}
return $models;
} | [
"public",
"function",
"createMany",
"(",
"array",
"$",
"data",
",",
"$",
"modelClass",
"=",
"null",
")",
"{",
"$",
"models",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"$",
"models",
"[",
"]",
"=",
"$",
"this",
... | Create many models from an array.
@param array $data
@param string $modelClass
@return ModelInterface[] | [
"Create",
"many",
"models",
"from",
"an",
"array",
"."
] | 7ff12b22cec4f118740cb1a7896508998d1cf96f | https://github.com/slince/shopify-api-php/blob/7ff12b22cec4f118740cb1a7896508998d1cf96f/src/Common/Manager/AbstractManager.php#L68-L76 | train |
slince/shopify-api-php | src/Client.php | Client.applyOptions | protected function applyOptions(array $options)
{
isset($options['httpClient']) && $this->httpClient = $options['httpClient'];
if (!isset($options['metaCacheDir'])) {
throw new InvalidArgumentException('You must provide option "metaCacheDir"');
}
$this->metaCacheDir = $options['metaCacheDir'];
} | php | protected function applyOptions(array $options)
{
isset($options['httpClient']) && $this->httpClient = $options['httpClient'];
if (!isset($options['metaCacheDir'])) {
throw new InvalidArgumentException('You must provide option "metaCacheDir"');
}
$this->metaCacheDir = $options['metaCacheDir'];
} | [
"protected",
"function",
"applyOptions",
"(",
"array",
"$",
"options",
")",
"{",
"isset",
"(",
"$",
"options",
"[",
"'httpClient'",
"]",
")",
"&&",
"$",
"this",
"->",
"httpClient",
"=",
"$",
"options",
"[",
"'httpClient'",
"]",
";",
"if",
"(",
"!",
"is... | Applies the array of request options to the client.
@param array $options | [
"Applies",
"the",
"array",
"of",
"request",
"options",
"to",
"the",
"client",
"."
] | 7ff12b22cec4f118740cb1a7896508998d1cf96f | https://github.com/slince/shopify-api-php/blob/7ff12b22cec4f118740cb1a7896508998d1cf96f/src/Client.php#L357-L364 | train |
slince/shopify-api-php | src/Client.php | Client.getHydrator | public function getHydrator()
{
if ($this->hydrator) {
return $this->hydrator;
}
return $this->hydrator = new Hydrator($this->metaCacheDir, $this->metaDirs);
} | php | public function getHydrator()
{
if ($this->hydrator) {
return $this->hydrator;
}
return $this->hydrator = new Hydrator($this->metaCacheDir, $this->metaDirs);
} | [
"public",
"function",
"getHydrator",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"this",
"->",
"hydrator",
";",
"}",
"return",
"$",
"this",
"->",
"hydrator",
"=",
"new",
"Hydrator",
"(",
"$",
"this",
"->",
"metaC... | Gets the hydrator instance.
@return Hydrator | [
"Gets",
"the",
"hydrator",
"instance",
"."
] | 7ff12b22cec4f118740cb1a7896508998d1cf96f | https://github.com/slince/shopify-api-php/blob/7ff12b22cec4f118740cb1a7896508998d1cf96f/src/Client.php#L371-L377 | train |
slince/shopify-api-php | src/Client.php | Client.addServiceClass | public function addServiceClass($serviceClass)
{
if (!is_subclass_of($serviceClass, ManagerInterface::class)) {
throw new InvalidArgumentException(sprintf('The service class "%s" should implement "ManagerInterface"', $serviceClass));
}
$this->serviceClass[] = $serviceClass;
$this->container->register($serviceClass::getServiceName(), $serviceClass);
} | php | public function addServiceClass($serviceClass)
{
if (!is_subclass_of($serviceClass, ManagerInterface::class)) {
throw new InvalidArgumentException(sprintf('The service class "%s" should implement "ManagerInterface"', $serviceClass));
}
$this->serviceClass[] = $serviceClass;
$this->container->register($serviceClass::getServiceName(), $serviceClass);
} | [
"public",
"function",
"addServiceClass",
"(",
"$",
"serviceClass",
")",
"{",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"serviceClass",
",",
"ManagerInterface",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'T... | Add a custom service class.
@param string $serviceClass
@throws InvalidArgumentException | [
"Add",
"a",
"custom",
"service",
"class",
"."
] | 7ff12b22cec4f118740cb1a7896508998d1cf96f | https://github.com/slince/shopify-api-php/blob/7ff12b22cec4f118740cb1a7896508998d1cf96f/src/Client.php#L400-L407 | train |
slince/shopify-api-php | src/Client.php | Client.initializeBaseServices | protected function initializeBaseServices()
{
foreach ($this->serviceClass as $serviceClass) {
$this->container->register($serviceClass::getServiceName(), $serviceClass);
}
} | php | protected function initializeBaseServices()
{
foreach ($this->serviceClass as $serviceClass) {
$this->container->register($serviceClass::getServiceName(), $serviceClass);
}
} | [
"protected",
"function",
"initializeBaseServices",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"serviceClass",
"as",
"$",
"serviceClass",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"register",
"(",
"$",
"serviceClass",
"::",
"getServiceName",
"(",
... | Initialize base services. | [
"Initialize",
"base",
"services",
"."
] | 7ff12b22cec4f118740cb1a7896508998d1cf96f | https://github.com/slince/shopify-api-php/blob/7ff12b22cec4f118740cb1a7896508998d1cf96f/src/Client.php#L412-L417 | train |
thephpleague/omnipay-stripe | src/Message/Response.php | Response.getOutcome | public function getOutcome()
{
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
if (isset($this->data['outcome']) && !empty($this->data['outcome'])) {
return $this->data['outcome'];
}
}
return null;
} | php | public function getOutcome()
{
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
if (isset($this->data['outcome']) && !empty($this->data['outcome'])) {
return $this->data['outcome'];
}
}
return null;
} | [
"public",
"function",
"getOutcome",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'object'",
"]",
")",
"&&",
"'charge'",
"===",
"$",
"this",
"->",
"data",
"[",
"'object'",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"t... | Get the outcome of a charge from the response
@return array|null | [
"Get",
"the",
"outcome",
"of",
"a",
"charge",
"from",
"the",
"response"
] | 769d8ab022c47d96e15414e885b292d934f848d8 | https://github.com/thephpleague/omnipay-stripe/blob/769d8ab022c47d96e15414e885b292d934f848d8/src/Message/Response.php#L70-L79 | train |
thephpleague/omnipay-stripe | src/Message/Response.php | Response.getTransactionReference | public function getTransactionReference()
{
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
return $this->data['id'];
}
if (isset($this->data['error']) && isset($this->data['error']['charge'])) {
return $this->data['error']['charge'];
}
return null;
} | php | public function getTransactionReference()
{
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
return $this->data['id'];
}
if (isset($this->data['error']) && isset($this->data['error']['charge'])) {
return $this->data['error']['charge'];
}
return null;
} | [
"public",
"function",
"getTransactionReference",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'object'",
"]",
")",
"&&",
"'charge'",
"===",
"$",
"this",
"->",
"data",
"[",
"'object'",
"]",
")",
"{",
"return",
"$",
"this",
... | Get the transaction reference.
@return string|null | [
"Get",
"the",
"transaction",
"reference",
"."
] | 769d8ab022c47d96e15414e885b292d934f848d8 | https://github.com/thephpleague/omnipay-stripe/blob/769d8ab022c47d96e15414e885b292d934f848d8/src/Message/Response.php#L86-L96 | train |
thephpleague/omnipay-stripe | src/Message/Response.php | Response.getBalanceTransactionReference | public function getBalanceTransactionReference()
{
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
return $this->data['balance_transaction'];
}
if (isset($this->data['object']) && 'balance_transaction' === $this->data['object']) {
return $this->data['id'];
}
if (isset($this->data['error']) && isset($this->data['error']['charge'])) {
return $this->data['error']['charge'];
}
return null;
} | php | public function getBalanceTransactionReference()
{
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
return $this->data['balance_transaction'];
}
if (isset($this->data['object']) && 'balance_transaction' === $this->data['object']) {
return $this->data['id'];
}
if (isset($this->data['error']) && isset($this->data['error']['charge'])) {
return $this->data['error']['charge'];
}
return null;
} | [
"public",
"function",
"getBalanceTransactionReference",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'object'",
"]",
")",
"&&",
"'charge'",
"===",
"$",
"this",
"->",
"data",
"[",
"'object'",
"]",
")",
"{",
"return",
"$",
"th... | Get the balance transaction reference.
@return string|null | [
"Get",
"the",
"balance",
"transaction",
"reference",
"."
] | 769d8ab022c47d96e15414e885b292d934f848d8 | https://github.com/thephpleague/omnipay-stripe/blob/769d8ab022c47d96e15414e885b292d934f848d8/src/Message/Response.php#L103-L116 | train |
thephpleague/omnipay-stripe | src/Message/Response.php | Response.getPlan | public function getPlan()
{
if (isset($this->data['plan'])) {
return $this->data['plan'];
} elseif (array_key_exists('object', $this->data) && $this->data['object'] == 'plan') {
return $this->data;
}
return null;
} | php | public function getPlan()
{
if (isset($this->data['plan'])) {
return $this->data['plan'];
} elseif (array_key_exists('object', $this->data) && $this->data['object'] == 'plan') {
return $this->data;
}
return null;
} | [
"public",
"function",
"getPlan",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'plan'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"'plan'",
"]",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'obje... | Get the subscription plan from the response of CreateSubscriptionRequest.
@return array|null | [
"Get",
"the",
"subscription",
"plan",
"from",
"the",
"response",
"of",
"CreateSubscriptionRequest",
"."
] | 769d8ab022c47d96e15414e885b292d934f848d8 | https://github.com/thephpleague/omnipay-stripe/blob/769d8ab022c47d96e15414e885b292d934f848d8/src/Message/Response.php#L311-L320 | train |
gocardless/gocardless-pro-php | lib/Core/Util.php | Util.subUrl | public static function subUrl($url, $substitutions)
{
foreach ($substitutions as $substitution_key => $substitution_value) {
if (!is_string($substitution_value)) {
$error_type = ' needs to be a string, not a '.gettype($substitution_value).'.';
throw new \Exception('URL value for ' . $substitution_key . $error_type);
}
$url = str_replace(':' . $substitution_key, $substitution_value, $url);
}
return $url;
} | php | public static function subUrl($url, $substitutions)
{
foreach ($substitutions as $substitution_key => $substitution_value) {
if (!is_string($substitution_value)) {
$error_type = ' needs to be a string, not a '.gettype($substitution_value).'.';
throw new \Exception('URL value for ' . $substitution_key . $error_type);
}
$url = str_replace(':' . $substitution_key, $substitution_value, $url);
}
return $url;
} | [
"public",
"static",
"function",
"subUrl",
"(",
"$",
"url",
",",
"$",
"substitutions",
")",
"{",
"foreach",
"(",
"$",
"substitutions",
"as",
"$",
"substitution_key",
"=>",
"$",
"substitution_value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"substitu... | Replace URL tokens with the substitution mapping to generate urls.
For example:
subUrl("/stats_for/:id", array("id" => "foo")) => "/stats_for/foo"
@param string $url Url to substitute
@param array $substitutions Substitutions to make
@return string the generated URL | [
"Replace",
"URL",
"tokens",
"with",
"the",
"substitution",
"mapping",
"to",
"generate",
"urls",
"."
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Core/Util.php#L69-L79 | train |
gocardless/gocardless-pro-php | lib/Webhook.php | Webhook.isSignatureValid | public static function isSignatureValid($request_body, $signature_header, $webhook_endpoint_secret)
{
$computed_signature = hash_hmac("sha256", $request_body, $webhook_endpoint_secret);
return hash_equals($computed_signature, $signature_header);
} | php | public static function isSignatureValid($request_body, $signature_header, $webhook_endpoint_secret)
{
$computed_signature = hash_hmac("sha256", $request_body, $webhook_endpoint_secret);
return hash_equals($computed_signature, $signature_header);
} | [
"public",
"static",
"function",
"isSignatureValid",
"(",
"$",
"request_body",
",",
"$",
"signature_header",
",",
"$",
"webhook_endpoint_secret",
")",
"{",
"$",
"computed_signature",
"=",
"hash_hmac",
"(",
"\"sha256\"",
",",
"$",
"request_body",
",",
"$",
"webhook_... | Validates that a webhook was genuinely sent by GoCardless by computing its
signature using the body and your webhook endpoint secret, and comparing that with
the signature included in the `Webhook-Signature` header.
@param string $request_body the request body
@param string $signature_header the signature included in the request, found in the `Webhook-Signature` header
`Webhook-Signature` header
@param string $webhook_endpoint_secret the webhook endpoint secret for your webhook
endpoint, as configured in your GoCardless Dashboard
@return boolean whether the webhook's signature is valid | [
"Validates",
"that",
"a",
"webhook",
"was",
"genuinely",
"sent",
"by",
"GoCardless",
"by",
"computing",
"its",
"signature",
"using",
"the",
"body",
"and",
"your",
"webhook",
"endpoint",
"secret",
"and",
"comparing",
"that",
"with",
"the",
"signature",
"included"... | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Webhook.php#L53-L57 | train |
gocardless/gocardless-pro-php | lib/Services/MandateImportsService.php | MandateImportsService.cancel | public function cancel($identity, $params = array())
{
$path = Util::subUrl(
'/mandate_imports/:identity/actions/cancel',
array(
'identity' => $identity
)
);
if(isset($params['params'])) {
$params['body'] = json_encode(array("data" => (object)$params['params']));
unset($params['params']);
}
try {
$response = $this->api_client->post($path, $params);
} catch(InvalidStateException $e) {
if ($e->isIdempotentCreationConflict()) {
return $this->get($e->getConflictingResourceId());
}
throw $e;
}
return $this->getResourceForResponse($response);
} | php | public function cancel($identity, $params = array())
{
$path = Util::subUrl(
'/mandate_imports/:identity/actions/cancel',
array(
'identity' => $identity
)
);
if(isset($params['params'])) {
$params['body'] = json_encode(array("data" => (object)$params['params']));
unset($params['params']);
}
try {
$response = $this->api_client->post($path, $params);
} catch(InvalidStateException $e) {
if ($e->isIdempotentCreationConflict()) {
return $this->get($e->getConflictingResourceId());
}
throw $e;
}
return $this->getResourceForResponse($response);
} | [
"public",
"function",
"cancel",
"(",
"$",
"identity",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"Util",
"::",
"subUrl",
"(",
"'/mandate_imports/:identity/actions/cancel'",
",",
"array",
"(",
"'identity'",
"=>",
"$",
"identity",
... | Cancel a mandate import
Example URL: /mandate_imports/:identity/actions/cancel
@param string $identity Unique identifier, beginning with "IM".
@param string[mixed] $params An associative array for any params
@return MandateImport | [
"Cancel",
"a",
"mandate",
"import"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Services/MandateImportsService.php#L137-L165 | train |
gocardless/gocardless-pro-php | lib/Core/Paginator.php | Paginator.next | public function next()
{
++$this->current_position;
if(!$this->valid()) {
$this->current_response = $this->next_response();
$this->current_page_position = $this->current_position;
}
} | php | public function next()
{
++$this->current_position;
if(!$this->valid()) {
$this->current_response = $this->next_response();
$this->current_page_position = $this->current_position;
}
} | [
"public",
"function",
"next",
"(",
")",
"{",
"++",
"$",
"this",
"->",
"current_position",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"current_response",
"=",
"$",
"this",
"->",
"next_response",
"(",
")",
... | Increments the current index of the iterator and fetches the next
page if required | [
"Increments",
"the",
"current",
"index",
"of",
"the",
"iterator",
"and",
"fetches",
"the",
"next",
"page",
"if",
"required"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Core/Paginator.php#L87-L95 | train |
gocardless/gocardless-pro-php | lib/Core/Paginator.php | Paginator.initial_response | private function initial_response()
{
$options = $this->options;
$options['params']['after'] = null;
return $this->service->list($options);
} | php | private function initial_response()
{
$options = $this->options;
$options['params']['after'] = null;
return $this->service->list($options);
} | [
"private",
"function",
"initial_response",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"options",
"[",
"'params'",
"]",
"[",
"'after'",
"]",
"=",
"null",
";",
"return",
"$",
"this",
"->",
"service",
"->",
"list",
"(",
... | Fetch the first page of results
@return ListResponse | [
"Fetch",
"the",
"first",
"page",
"of",
"results"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Core/Paginator.php#L113-L118 | train |
gocardless/gocardless-pro-php | lib/RetryMiddlewareFactory.php | RetryMiddlewareFactory.buildRetryDecider | private static function buildRetryDecider()
{
return function (
$retries,
\GuzzleHttp\Psr7\Request $request,
\GuzzleHttp\Psr7\Response $response = null,
\GuzzleHttp\Exception\RequestException $exception = null
) {
if ($retries >= self::MAX_AUTOMATIC_TIMEOUT_RETRIES) {
return false;
}
if (!self::isConnectionError($exception) && !self::isRetryableServerError($response)) {
return false;
}
if ($request->getMethod() == "GET" || $request->getMethod() == "PUT") {
return true;
}
$path = $request->getUri()->getPath();
if ($request->getMethod() == "POST") {
if (!preg_match(self::ACTIONS_PATH_REGEX, $path)) {
return true;
}
}
return false;
};
} | php | private static function buildRetryDecider()
{
return function (
$retries,
\GuzzleHttp\Psr7\Request $request,
\GuzzleHttp\Psr7\Response $response = null,
\GuzzleHttp\Exception\RequestException $exception = null
) {
if ($retries >= self::MAX_AUTOMATIC_TIMEOUT_RETRIES) {
return false;
}
if (!self::isConnectionError($exception) && !self::isRetryableServerError($response)) {
return false;
}
if ($request->getMethod() == "GET" || $request->getMethod() == "PUT") {
return true;
}
$path = $request->getUri()->getPath();
if ($request->getMethod() == "POST") {
if (!preg_match(self::ACTIONS_PATH_REGEX, $path)) {
return true;
}
}
return false;
};
} | [
"private",
"static",
"function",
"buildRetryDecider",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"retries",
",",
"\\",
"GuzzleHttp",
"\\",
"Psr7",
"\\",
"Request",
"$",
"request",
",",
"\\",
"GuzzleHttp",
"\\",
"Psr7",
"\\",
"Response",
"$",
"response",
... | Internal function for building a retry decider for the Guzzle Retry middleware
@return callable A function called to decide whether to retry a request | [
"Internal",
"function",
"for",
"building",
"a",
"retry",
"decider",
"for",
"the",
"Guzzle",
"Retry",
"middleware"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/RetryMiddlewareFactory.php#L28-L58 | train |
gocardless/gocardless-pro-php | lib/RetryMiddlewareFactory.php | RetryMiddlewareFactory.isConnectionError | private static function isConnectionError(\GuzzleHttp\Exception\RequestException $exception = null)
{
return $exception instanceof \GuzzleHttp\Exception\ConnectException;
} | php | private static function isConnectionError(\GuzzleHttp\Exception\RequestException $exception = null)
{
return $exception instanceof \GuzzleHttp\Exception\ConnectException;
} | [
"private",
"static",
"function",
"isConnectionError",
"(",
"\\",
"GuzzleHttp",
"\\",
"Exception",
"\\",
"RequestException",
"$",
"exception",
"=",
"null",
")",
"{",
"return",
"$",
"exception",
"instanceof",
"\\",
"GuzzleHttp",
"\\",
"Exception",
"\\",
"ConnectExce... | Internal function for determining if a request hit a connection error
@return boolean | [
"Internal",
"function",
"for",
"determining",
"if",
"a",
"request",
"hit",
"a",
"connection",
"error"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/RetryMiddlewareFactory.php#L77-L80 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.bankDetailsLookups | public function bankDetailsLookups()
{
if (!isset($this->bank_details_lookups)) {
$this->bank_details_lookups = new Services\BankDetailsLookupsService($this->api_client);
}
return $this->bank_details_lookups;
} | php | public function bankDetailsLookups()
{
if (!isset($this->bank_details_lookups)) {
$this->bank_details_lookups = new Services\BankDetailsLookupsService($this->api_client);
}
return $this->bank_details_lookups;
} | [
"public",
"function",
"bankDetailsLookups",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bank_details_lookups",
")",
")",
"{",
"$",
"this",
"->",
"bank_details_lookups",
"=",
"new",
"Services",
"\\",
"BankDetailsLookupsService",
"(",
"$",
... | Service for interacting with bank details lookups
@return Services\BankDetailsLookupsService | [
"Service",
"for",
"interacting",
"with",
"bank",
"details",
"lookups"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L73-L80 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.creditors | public function creditors()
{
if (!isset($this->creditors)) {
$this->creditors = new Services\CreditorsService($this->api_client);
}
return $this->creditors;
} | php | public function creditors()
{
if (!isset($this->creditors)) {
$this->creditors = new Services\CreditorsService($this->api_client);
}
return $this->creditors;
} | [
"public",
"function",
"creditors",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"creditors",
")",
")",
"{",
"$",
"this",
"->",
"creditors",
"=",
"new",
"Services",
"\\",
"CreditorsService",
"(",
"$",
"this",
"->",
"api_client",
")",
... | Service for interacting with creditors
@return Services\CreditorsService | [
"Service",
"for",
"interacting",
"with",
"creditors"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L86-L93 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.creditorBankAccounts | public function creditorBankAccounts()
{
if (!isset($this->creditor_bank_accounts)) {
$this->creditor_bank_accounts = new Services\CreditorBankAccountsService($this->api_client);
}
return $this->creditor_bank_accounts;
} | php | public function creditorBankAccounts()
{
if (!isset($this->creditor_bank_accounts)) {
$this->creditor_bank_accounts = new Services\CreditorBankAccountsService($this->api_client);
}
return $this->creditor_bank_accounts;
} | [
"public",
"function",
"creditorBankAccounts",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"creditor_bank_accounts",
")",
")",
"{",
"$",
"this",
"->",
"creditor_bank_accounts",
"=",
"new",
"Services",
"\\",
"CreditorBankAccountsService",
"(",
... | Service for interacting with creditor bank accounts
@return Services\CreditorBankAccountsService | [
"Service",
"for",
"interacting",
"with",
"creditor",
"bank",
"accounts"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L99-L106 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.customers | public function customers()
{
if (!isset($this->customers)) {
$this->customers = new Services\CustomersService($this->api_client);
}
return $this->customers;
} | php | public function customers()
{
if (!isset($this->customers)) {
$this->customers = new Services\CustomersService($this->api_client);
}
return $this->customers;
} | [
"public",
"function",
"customers",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"customers",
")",
")",
"{",
"$",
"this",
"->",
"customers",
"=",
"new",
"Services",
"\\",
"CustomersService",
"(",
"$",
"this",
"->",
"api_client",
")",
... | Service for interacting with customers
@return Services\CustomersService | [
"Service",
"for",
"interacting",
"with",
"customers"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L112-L119 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.customerBankAccounts | public function customerBankAccounts()
{
if (!isset($this->customer_bank_accounts)) {
$this->customer_bank_accounts = new Services\CustomerBankAccountsService($this->api_client);
}
return $this->customer_bank_accounts;
} | php | public function customerBankAccounts()
{
if (!isset($this->customer_bank_accounts)) {
$this->customer_bank_accounts = new Services\CustomerBankAccountsService($this->api_client);
}
return $this->customer_bank_accounts;
} | [
"public",
"function",
"customerBankAccounts",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"customer_bank_accounts",
")",
")",
"{",
"$",
"this",
"->",
"customer_bank_accounts",
"=",
"new",
"Services",
"\\",
"CustomerBankAccountsService",
"(",
... | Service for interacting with customer bank accounts
@return Services\CustomerBankAccountsService | [
"Service",
"for",
"interacting",
"with",
"customer",
"bank",
"accounts"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L125-L132 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.customerNotifications | public function customerNotifications()
{
if (!isset($this->customer_notifications)) {
$this->customer_notifications = new Services\CustomerNotificationsService($this->api_client);
}
return $this->customer_notifications;
} | php | public function customerNotifications()
{
if (!isset($this->customer_notifications)) {
$this->customer_notifications = new Services\CustomerNotificationsService($this->api_client);
}
return $this->customer_notifications;
} | [
"public",
"function",
"customerNotifications",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"customer_notifications",
")",
")",
"{",
"$",
"this",
"->",
"customer_notifications",
"=",
"new",
"Services",
"\\",
"CustomerNotificationsService",
"("... | Service for interacting with customer notifications
@return Services\CustomerNotificationsService | [
"Service",
"for",
"interacting",
"with",
"customer",
"notifications"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L138-L145 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.events | public function events()
{
if (!isset($this->events)) {
$this->events = new Services\EventsService($this->api_client);
}
return $this->events;
} | php | public function events()
{
if (!isset($this->events)) {
$this->events = new Services\EventsService($this->api_client);
}
return $this->events;
} | [
"public",
"function",
"events",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"events",
")",
")",
"{",
"$",
"this",
"->",
"events",
"=",
"new",
"Services",
"\\",
"EventsService",
"(",
"$",
"this",
"->",
"api_client",
")",
";",
"}"... | Service for interacting with events
@return Services\EventsService | [
"Service",
"for",
"interacting",
"with",
"events"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L151-L158 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.mandates | public function mandates()
{
if (!isset($this->mandates)) {
$this->mandates = new Services\MandatesService($this->api_client);
}
return $this->mandates;
} | php | public function mandates()
{
if (!isset($this->mandates)) {
$this->mandates = new Services\MandatesService($this->api_client);
}
return $this->mandates;
} | [
"public",
"function",
"mandates",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mandates",
")",
")",
"{",
"$",
"this",
"->",
"mandates",
"=",
"new",
"Services",
"\\",
"MandatesService",
"(",
"$",
"this",
"->",
"api_client",
")",
";... | Service for interacting with mandates
@return Services\MandatesService | [
"Service",
"for",
"interacting",
"with",
"mandates"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L164-L171 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.mandateImports | public function mandateImports()
{
if (!isset($this->mandate_imports)) {
$this->mandate_imports = new Services\MandateImportsService($this->api_client);
}
return $this->mandate_imports;
} | php | public function mandateImports()
{
if (!isset($this->mandate_imports)) {
$this->mandate_imports = new Services\MandateImportsService($this->api_client);
}
return $this->mandate_imports;
} | [
"public",
"function",
"mandateImports",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mandate_imports",
")",
")",
"{",
"$",
"this",
"->",
"mandate_imports",
"=",
"new",
"Services",
"\\",
"MandateImportsService",
"(",
"$",
"this",
"->",
... | Service for interacting with mandate imports
@return Services\MandateImportsService | [
"Service",
"for",
"interacting",
"with",
"mandate",
"imports"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L177-L184 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.mandateImportEntries | public function mandateImportEntries()
{
if (!isset($this->mandate_import_entries)) {
$this->mandate_import_entries = new Services\MandateImportEntriesService($this->api_client);
}
return $this->mandate_import_entries;
} | php | public function mandateImportEntries()
{
if (!isset($this->mandate_import_entries)) {
$this->mandate_import_entries = new Services\MandateImportEntriesService($this->api_client);
}
return $this->mandate_import_entries;
} | [
"public",
"function",
"mandateImportEntries",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mandate_import_entries",
")",
")",
"{",
"$",
"this",
"->",
"mandate_import_entries",
"=",
"new",
"Services",
"\\",
"MandateImportEntriesService",
"(",
... | Service for interacting with mandate import entries
@return Services\MandateImportEntriesService | [
"Service",
"for",
"interacting",
"with",
"mandate",
"import",
"entries"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L190-L197 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.mandatePdfs | public function mandatePdfs()
{
if (!isset($this->mandate_pdfs)) {
$this->mandate_pdfs = new Services\MandatePdfsService($this->api_client);
}
return $this->mandate_pdfs;
} | php | public function mandatePdfs()
{
if (!isset($this->mandate_pdfs)) {
$this->mandate_pdfs = new Services\MandatePdfsService($this->api_client);
}
return $this->mandate_pdfs;
} | [
"public",
"function",
"mandatePdfs",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mandate_pdfs",
")",
")",
"{",
"$",
"this",
"->",
"mandate_pdfs",
"=",
"new",
"Services",
"\\",
"MandatePdfsService",
"(",
"$",
"this",
"->",
"api_client... | Service for interacting with mandate pdfs
@return Services\MandatePdfsService | [
"Service",
"for",
"interacting",
"with",
"mandate",
"pdfs"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L203-L210 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.payments | public function payments()
{
if (!isset($this->payments)) {
$this->payments = new Services\PaymentsService($this->api_client);
}
return $this->payments;
} | php | public function payments()
{
if (!isset($this->payments)) {
$this->payments = new Services\PaymentsService($this->api_client);
}
return $this->payments;
} | [
"public",
"function",
"payments",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payments",
")",
")",
"{",
"$",
"this",
"->",
"payments",
"=",
"new",
"Services",
"\\",
"PaymentsService",
"(",
"$",
"this",
"->",
"api_client",
")",
";... | Service for interacting with payments
@return Services\PaymentsService | [
"Service",
"for",
"interacting",
"with",
"payments"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L216-L223 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.payouts | public function payouts()
{
if (!isset($this->payouts)) {
$this->payouts = new Services\PayoutsService($this->api_client);
}
return $this->payouts;
} | php | public function payouts()
{
if (!isset($this->payouts)) {
$this->payouts = new Services\PayoutsService($this->api_client);
}
return $this->payouts;
} | [
"public",
"function",
"payouts",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payouts",
")",
")",
"{",
"$",
"this",
"->",
"payouts",
"=",
"new",
"Services",
"\\",
"PayoutsService",
"(",
"$",
"this",
"->",
"api_client",
")",
";",
... | Service for interacting with payouts
@return Services\PayoutsService | [
"Service",
"for",
"interacting",
"with",
"payouts"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L229-L236 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.payoutItems | public function payoutItems()
{
if (!isset($this->payout_items)) {
$this->payout_items = new Services\PayoutItemsService($this->api_client);
}
return $this->payout_items;
} | php | public function payoutItems()
{
if (!isset($this->payout_items)) {
$this->payout_items = new Services\PayoutItemsService($this->api_client);
}
return $this->payout_items;
} | [
"public",
"function",
"payoutItems",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payout_items",
")",
")",
"{",
"$",
"this",
"->",
"payout_items",
"=",
"new",
"Services",
"\\",
"PayoutItemsService",
"(",
"$",
"this",
"->",
"api_client... | Service for interacting with payout items
@return Services\PayoutItemsService | [
"Service",
"for",
"interacting",
"with",
"payout",
"items"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L242-L249 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.redirectFlows | public function redirectFlows()
{
if (!isset($this->redirect_flows)) {
$this->redirect_flows = new Services\RedirectFlowsService($this->api_client);
}
return $this->redirect_flows;
} | php | public function redirectFlows()
{
if (!isset($this->redirect_flows)) {
$this->redirect_flows = new Services\RedirectFlowsService($this->api_client);
}
return $this->redirect_flows;
} | [
"public",
"function",
"redirectFlows",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"redirect_flows",
")",
")",
"{",
"$",
"this",
"->",
"redirect_flows",
"=",
"new",
"Services",
"\\",
"RedirectFlowsService",
"(",
"$",
"this",
"->",
"ap... | Service for interacting with redirect flows
@return Services\RedirectFlowsService | [
"Service",
"for",
"interacting",
"with",
"redirect",
"flows"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L255-L262 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.refunds | public function refunds()
{
if (!isset($this->refunds)) {
$this->refunds = new Services\RefundsService($this->api_client);
}
return $this->refunds;
} | php | public function refunds()
{
if (!isset($this->refunds)) {
$this->refunds = new Services\RefundsService($this->api_client);
}
return $this->refunds;
} | [
"public",
"function",
"refunds",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"refunds",
")",
")",
"{",
"$",
"this",
"->",
"refunds",
"=",
"new",
"Services",
"\\",
"RefundsService",
"(",
"$",
"this",
"->",
"api_client",
")",
";",
... | Service for interacting with refunds
@return Services\RefundsService | [
"Service",
"for",
"interacting",
"with",
"refunds"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L268-L275 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.subscriptions | public function subscriptions()
{
if (!isset($this->subscriptions)) {
$this->subscriptions = new Services\SubscriptionsService($this->api_client);
}
return $this->subscriptions;
} | php | public function subscriptions()
{
if (!isset($this->subscriptions)) {
$this->subscriptions = new Services\SubscriptionsService($this->api_client);
}
return $this->subscriptions;
} | [
"public",
"function",
"subscriptions",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"subscriptions",
")",
")",
"{",
"$",
"this",
"->",
"subscriptions",
"=",
"new",
"Services",
"\\",
"SubscriptionsService",
"(",
"$",
"this",
"->",
"api_... | Service for interacting with subscriptions
@return Services\SubscriptionsService | [
"Service",
"for",
"interacting",
"with",
"subscriptions"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L281-L288 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.validate_config | private function validate_config($config)
{
$required_option_keys = array('access_token', 'environment');
foreach ($required_option_keys as $required_option_key) {
if (!isset($config[$required_option_key])) {
throw new \Exception('Missing required option `' . $required_option_key . '`.');
}
if (!is_string($config[$required_option_key])) {
throw new \Exception('Option `'. $required_option_key .'` can only be a string.');
}
}
} | php | private function validate_config($config)
{
$required_option_keys = array('access_token', 'environment');
foreach ($required_option_keys as $required_option_key) {
if (!isset($config[$required_option_key])) {
throw new \Exception('Missing required option `' . $required_option_key . '`.');
}
if (!is_string($config[$required_option_key])) {
throw new \Exception('Option `'. $required_option_key .'` can only be a string.');
}
}
} | [
"private",
"function",
"validate_config",
"(",
"$",
"config",
")",
"{",
"$",
"required_option_keys",
"=",
"array",
"(",
"'access_token'",
",",
"'environment'",
")",
";",
"foreach",
"(",
"$",
"required_option_keys",
"as",
"$",
"required_option_key",
")",
"{",
"if... | Ensures a config is valid and sets defaults where required
@param array[string]mixed $config the client configuration options | [
"Ensures",
"a",
"config",
"is",
"valid",
"and",
"sets",
"defaults",
"where",
"required"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L309-L322 | train |
gocardless/gocardless-pro-php | lib/Client.php | Client.getUserAgent | private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/3.0.0';
$uagent[] = 'schema-version/2015-07-06';
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::VERSION;
$uagent[] = 'php/' . phpversion();
if (extension_loaded('curl') && function_exists('curl_version')) {
$uagent[] = 'curl/' . \curl_version()['version'];
$uagent[] = 'curl/' . \curl_version()['host'];
}
return implode(' ', $uagent);
} | php | private function getUserAgent()
{
$curlinfo = curl_version();
$uagent = array();
$uagent[] = 'gocardless-pro-php/3.0.0';
$uagent[] = 'schema-version/2015-07-06';
$uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::VERSION;
$uagent[] = 'php/' . phpversion();
if (extension_loaded('curl') && function_exists('curl_version')) {
$uagent[] = 'curl/' . \curl_version()['version'];
$uagent[] = 'curl/' . \curl_version()['host'];
}
return implode(' ', $uagent);
} | [
"private",
"function",
"getUserAgent",
"(",
")",
"{",
"$",
"curlinfo",
"=",
"curl_version",
"(",
")",
";",
"$",
"uagent",
"=",
"array",
"(",
")",
";",
"$",
"uagent",
"[",
"]",
"=",
"'gocardless-pro-php/3.0.0'",
";",
"$",
"uagent",
"[",
"]",
"=",
"'sche... | Gets the client's user agent for API calls
@return string | [
"Gets",
"the",
"client",
"s",
"user",
"agent",
"for",
"API",
"calls"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Client.php#L329-L342 | train |
gocardless/gocardless-pro-php | lib/Services/SubscriptionsService.php | SubscriptionsService.get | public function get($identity, $params = array())
{
$path = Util::subUrl(
'/subscriptions/:identity',
array(
'identity' => $identity
)
);
if(isset($params['params'])) { $params['query'] = $params['params'];
unset($params['params']);
}
$response = $this->api_client->get($path, $params);
return $this->getResourceForResponse($response);
} | php | public function get($identity, $params = array())
{
$path = Util::subUrl(
'/subscriptions/:identity',
array(
'identity' => $identity
)
);
if(isset($params['params'])) { $params['query'] = $params['params'];
unset($params['params']);
}
$response = $this->api_client->get($path, $params);
return $this->getResourceForResponse($response);
} | [
"public",
"function",
"get",
"(",
"$",
"identity",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"Util",
"::",
"subUrl",
"(",
"'/subscriptions/:identity'",
",",
"array",
"(",
"'identity'",
"=>",
"$",
"identity",
")",
")",
";",... | Get a single subscription
Example URL: /subscriptions/:identity
@param string $identity Unique identifier, beginning with "SB".
@param string[mixed] $params An associative array for any params
@return Subscription | [
"Get",
"a",
"single",
"subscription"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Services/SubscriptionsService.php#L91-L109 | train |
gocardless/gocardless-pro-php | lib/Services/SubscriptionsService.php | SubscriptionsService.update | public function update($identity, $params = array())
{
$path = Util::subUrl(
'/subscriptions/:identity',
array(
'identity' => $identity
)
);
if(isset($params['params'])) {
$params['body'] = json_encode(array($this->envelope_key => (object)$params['params']));
unset($params['params']);
}
$response = $this->api_client->put($path, $params);
return $this->getResourceForResponse($response);
} | php | public function update($identity, $params = array())
{
$path = Util::subUrl(
'/subscriptions/:identity',
array(
'identity' => $identity
)
);
if(isset($params['params'])) {
$params['body'] = json_encode(array($this->envelope_key => (object)$params['params']));
unset($params['params']);
}
$response = $this->api_client->put($path, $params);
return $this->getResourceForResponse($response);
} | [
"public",
"function",
"update",
"(",
"$",
"identity",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"Util",
"::",
"subUrl",
"(",
"'/subscriptions/:identity'",
",",
"array",
"(",
"'identity'",
"=>",
"$",
"identity",
")",
")",
"... | Update a subscription
Example URL: /subscriptions/:identity
@param string $identity Unique identifier, beginning with "SB".
@param string[mixed] $params An associative array for any params
@return Subscription | [
"Update",
"a",
"subscription"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Services/SubscriptionsService.php#L120-L140 | train |
gocardless/gocardless-pro-php | lib/Core/ApiClient.php | ApiClient.handleErrors | private function handleErrors($response)
{
$json = json_decode($response->getBody());
if ($json === null) {
$msg = "Malformed response received from server";
throw new Exception\MalformedResponseException($msg, $response);
}
if ($response->getStatusCode() < 400) {
return null;
}
$error = $json->error;
$exception_class = (string) ApiException::getErrorForType($error->type);
$exception_class = 'GoCardlessPro\\Core\\Exception\\' . $exception_class;
$api_response = new ApiResponse($response);
throw new $exception_class($api_response);
} | php | private function handleErrors($response)
{
$json = json_decode($response->getBody());
if ($json === null) {
$msg = "Malformed response received from server";
throw new Exception\MalformedResponseException($msg, $response);
}
if ($response->getStatusCode() < 400) {
return null;
}
$error = $json->error;
$exception_class = (string) ApiException::getErrorForType($error->type);
$exception_class = 'GoCardlessPro\\Core\\Exception\\' . $exception_class;
$api_response = new ApiResponse($response);
throw new $exception_class($api_response);
} | [
"private",
"function",
"handleErrors",
"(",
"$",
"response",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"if",
"(",
"$",
"json",
"===",
"null",
")",
"{",
"$",
"msg",
"=",
"\"Malformed response r... | Handle any errors in the API response
If the response doesn't contain JSON, we will fail to decode and throw a
MalFormedResponseException.
If the response is JSON, but the status code is >= 400, then we return
the appropriate error depending on the code
@param GuzzleHttp\Psr7\Response $response The raw API response | [
"Handle",
"any",
"errors",
"in",
"the",
"API",
"response"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Core/ApiClient.php#L93-L112 | train |
gocardless/gocardless-pro-php | lib/Core/ApiClient.php | ApiClient.castBooleanValuesToStrings | private function castBooleanValuesToStrings($query)
{
return array_map(
function ($value) {
if ($value === true) {
return "true";
} elseif ($value === false) {
return "false";
} elseif (is_array($value)) {
return $this->castBooleanValuesToStrings($value);
} else {
return $value;
}
}, $query
);
} | php | private function castBooleanValuesToStrings($query)
{
return array_map(
function ($value) {
if ($value === true) {
return "true";
} elseif ($value === false) {
return "false";
} elseif (is_array($value)) {
return $this->castBooleanValuesToStrings($value);
} else {
return $value;
}
}, $query
);
} | [
"private",
"function",
"castBooleanValuesToStrings",
"(",
"$",
"query",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"return",
"\"true\"",
";",
"}",
"elseif",
"(",
"$",
... | Recursively maps through an array, casting any booleans to strings, where
true should be casted as "true", and false as "false". We use this to
prepare query parameters to be sent to the API, since PHP's in-build
http_build_query casts booleans as "1" and "" respectively, which is odd.
@param array $query An array to map through, casting booleans to strings
@return array The new array with booleans casted to strings | [
"Recursively",
"maps",
"through",
"an",
"array",
"casting",
"any",
"booleans",
"to",
"strings",
"where",
"true",
"should",
"be",
"casted",
"as",
"true",
"and",
"false",
"as",
"false",
".",
"We",
"use",
"this",
"to",
"prepare",
"query",
"parameters",
"to",
... | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Core/ApiClient.php#L124-L139 | train |
gocardless/gocardless-pro-php | lib/Services/BaseService.php | BaseService.getResourceForResponse | protected function getResourceForResponse($response)
{
$api_response = new \GoCardlessPro\Core\ApiResponse($response);
$unenveloped_body = $this->getUnenvelopedBody($api_response->body);
if(is_array($unenveloped_body)) {
return new ListResponse($unenveloped_body, $this->resource_class, $api_response);
} else {
$rclass = $this->resource_class;
return new $rclass($unenveloped_body, $api_response);
}
} | php | protected function getResourceForResponse($response)
{
$api_response = new \GoCardlessPro\Core\ApiResponse($response);
$unenveloped_body = $this->getUnenvelopedBody($api_response->body);
if(is_array($unenveloped_body)) {
return new ListResponse($unenveloped_body, $this->resource_class, $api_response);
} else {
$rclass = $this->resource_class;
return new $rclass($unenveloped_body, $api_response);
}
} | [
"protected",
"function",
"getResourceForResponse",
"(",
"$",
"response",
")",
"{",
"$",
"api_response",
"=",
"new",
"\\",
"GoCardlessPro",
"\\",
"Core",
"\\",
"ApiResponse",
"(",
"$",
"response",
")",
";",
"$",
"unenveloped_body",
"=",
"$",
"this",
"->",
"ge... | Takes a raw response and returns either an instantiated resource or a
ListResponse
@param array $response The raw API response
@return ListResponse|\GoCardlessPro\Resources\BaseResource | [
"Takes",
"a",
"raw",
"response",
"and",
"returns",
"either",
"an",
"instantiated",
"resource",
"or",
"a",
"ListResponse"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Services/BaseService.php#L62-L73 | train |
gocardless/gocardless-pro-php | lib/Services/MandatePdfsService.php | MandatePdfsService.create | public function create($params = array())
{
$path = "/mandate_pdfs";
if(isset($params['params'])) {
$params['body'] = json_encode(array($this->envelope_key => (object)$params['params']));
unset($params['params']);
}
$response = $this->api_client->post($path, $params);
return $this->getResourceForResponse($response);
} | php | public function create($params = array())
{
$path = "/mandate_pdfs";
if(isset($params['params'])) {
$params['body'] = json_encode(array($this->envelope_key => (object)$params['params']));
unset($params['params']);
}
$response = $this->api_client->post($path, $params);
return $this->getResourceForResponse($response);
} | [
"public",
"function",
"create",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"\"/mandate_pdfs\"",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'params'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'body'",
"]",
"=",
... | Create a mandate PDF
Example URL: /mandate_pdfs
@param string[mixed] $params An associative array for any params
@return MandatePdf | [
"Create",
"a",
"mandate",
"PDF"
] | c52c9cd7049995dcf46c354275e14c6a6abb0129 | https://github.com/gocardless/gocardless-pro-php/blob/c52c9cd7049995dcf46c354275e14c6a6abb0129/lib/Services/MandatePdfsService.php#L36-L50 | train |
lexik/LexikTranslationBundle | Translation/Exporter/ExporterCollector.php | ExporterCollector.getByFormat | public function getByFormat($format)
{
foreach ($this->getExporters() as $exporter) {
if ($exporter->support($format)) {
return $exporter;
}
}
throw new \RuntimeException(sprintf('No exporter found for "%s" format.', $format));
} | php | public function getByFormat($format)
{
foreach ($this->getExporters() as $exporter) {
if ($exporter->support($format)) {
return $exporter;
}
}
throw new \RuntimeException(sprintf('No exporter found for "%s" format.', $format));
} | [
"public",
"function",
"getByFormat",
"(",
"$",
"format",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getExporters",
"(",
")",
"as",
"$",
"exporter",
")",
"{",
"if",
"(",
"$",
"exporter",
"->",
"support",
"(",
"$",
"format",
")",
")",
"{",
"return",... | Returns an exporter that support the given format.
@param string $format
@return ExporterInterface
@throws \RuntimeException | [
"Returns",
"an",
"exporter",
"that",
"support",
"the",
"given",
"format",
"."
] | 91d18448a460a42b467be0b22ea5b47e11d42856 | https://github.com/lexik/LexikTranslationBundle/blob/91d18448a460a42b467be0b22ea5b47e11d42856/Translation/Exporter/ExporterCollector.php#L42-L51 | train |
lexik/LexikTranslationBundle | Command/ExportTranslationsCommand.php | ExportTranslationsCommand.getFilesToExport | protected function getFilesToExport()
{
$locales = $this->input->getOption('locales') ? explode(',', $this->input->getOption('locales')) : array();
$domains = $this->input->getOption('domains') ? explode(',', $this->input->getOption('domains')) : array();
return $this->getContainer()
->get('lexik_translation.translation_storage')
->getFilesByLocalesAndDomains($locales, $domains);
} | php | protected function getFilesToExport()
{
$locales = $this->input->getOption('locales') ? explode(',', $this->input->getOption('locales')) : array();
$domains = $this->input->getOption('domains') ? explode(',', $this->input->getOption('domains')) : array();
return $this->getContainer()
->get('lexik_translation.translation_storage')
->getFilesByLocalesAndDomains($locales, $domains);
} | [
"protected",
"function",
"getFilesToExport",
"(",
")",
"{",
"$",
"locales",
"=",
"$",
"this",
"->",
"input",
"->",
"getOption",
"(",
"'locales'",
")",
"?",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"input",
"->",
"getOption",
"(",
"'locales'",
")",
... | Returns all file to export.
@return array | [
"Returns",
"all",
"file",
"to",
"export",
"."
] | 91d18448a460a42b467be0b22ea5b47e11d42856 | https://github.com/lexik/LexikTranslationBundle/blob/91d18448a460a42b467be0b22ea5b47e11d42856/Command/ExportTranslationsCommand.php#L68-L76 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.