repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
oscarotero/Embed | src/Utils.php | Utils.videoHtml | public static function videoHtml($poster, $sources, $width = 0, $height = 0)
{
$code = self::element('video', [
'poster' => ($poster ?: null),
'width' => ($width ?: null),
'height' => ($height ?: null),
'controls' => true,
]);
foreach ((array)... | php | public static function videoHtml($poster, $sources, $width = 0, $height = 0)
{
$code = self::element('video', [
'poster' => ($poster ?: null),
'width' => ($width ?: null),
'height' => ($height ?: null),
'controls' => true,
]);
foreach ((array)... | [
"public",
"static",
"function",
"videoHtml",
"(",
"$",
"poster",
",",
"$",
"sources",
",",
"$",
"width",
"=",
"0",
",",
"$",
"height",
"=",
"0",
")",
"{",
"$",
"code",
"=",
"self",
"::",
"element",
"(",
"'video'",
",",
"[",
"'poster'",
"=>",
"(",
... | Creates a <video> element.
@param string $poster Poster attribute
@param string|array $sources Video sources
@param int $width Width attribute
@param int $height Height attribute
@return string | [
"Creates",
"a",
"<video",
">",
"element",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L25-L39 |
oscarotero/Embed | src/Utils.php | Utils.audioHtml | public static function audioHtml($sources)
{
$code = '<audio controls>';
foreach ((array) $sources as $source) {
$code .= self::element('source', ['src' => $source]);
}
return $code.'</audio>';
} | php | public static function audioHtml($sources)
{
$code = '<audio controls>';
foreach ((array) $sources as $source) {
$code .= self::element('source', ['src' => $source]);
}
return $code.'</audio>';
} | [
"public",
"static",
"function",
"audioHtml",
"(",
"$",
"sources",
")",
"{",
"$",
"code",
"=",
"'<audio controls>'",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"sources",
"as",
"$",
"source",
")",
"{",
"$",
"code",
".=",
"self",
"::",
"element",
"(",
... | Creates an <audio> element.
@param string|array $sources Audio sources
@return string | [
"Creates",
"an",
"<audio",
">",
"element",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L48-L57 |
oscarotero/Embed | src/Utils.php | Utils.imageHtml | public static function imageHtml($src, $alt = '', $width = 0, $height = 0)
{
return self::element('img', [
'src' => $src,
'alt' => $alt,
'width' => ($width ?: null),
'height' => ($height ?: null),
]);
} | php | public static function imageHtml($src, $alt = '', $width = 0, $height = 0)
{
return self::element('img', [
'src' => $src,
'alt' => $alt,
'width' => ($width ?: null),
'height' => ($height ?: null),
]);
} | [
"public",
"static",
"function",
"imageHtml",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"''",
",",
"$",
"width",
"=",
"0",
",",
"$",
"height",
"=",
"0",
")",
"{",
"return",
"self",
"::",
"element",
"(",
"'img'",
",",
"[",
"'src'",
"=>",
"$",
"src",
... | Creates an <img> element.
@param string $src Image source attribute
@param string $alt Alt attribute
@param int $width Width attribute
@param int $height Height attribute
@return string | [
"Creates",
"an",
"<img",
">",
"element",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L69-L77 |
oscarotero/Embed | src/Utils.php | Utils.iframe | public static function iframe($src, $width = 0, $height = 0, $styles = '')
{
$width = $width ? (is_int($width) ? $width.'px' : $width) : '600px';
$height = $height ? (is_int($height) ? $height.'px' : $height) : '400px';
if (empty($styles)) {
$styles = 'border:none;overflow:hidde... | php | public static function iframe($src, $width = 0, $height = 0, $styles = '')
{
$width = $width ? (is_int($width) ? $width.'px' : $width) : '600px';
$height = $height ? (is_int($height) ? $height.'px' : $height) : '400px';
if (empty($styles)) {
$styles = 'border:none;overflow:hidde... | [
"public",
"static",
"function",
"iframe",
"(",
"$",
"src",
",",
"$",
"width",
"=",
"0",
",",
"$",
"height",
"=",
"0",
",",
"$",
"styles",
"=",
"''",
")",
"{",
"$",
"width",
"=",
"$",
"width",
"?",
"(",
"is_int",
"(",
"$",
"width",
")",
"?",
"... | Creates an <iframe> element.
@param string $src Iframe source attribute
@param int $width Width attribute
@param int $height Height attribute
@param int $styles Extra css styles
@return string | [
"Creates",
"an",
"<iframe",
">",
"element",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L89-L106 |
oscarotero/Embed | src/Utils.php | Utils.flash | public static function flash($src, $width = null, $height = null)
{
$code = self::element('object', [
'width' => $width ?: 600,
'height' => $height ?: 400,
'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
'codebase' => 'http://download.macromedia.com... | php | public static function flash($src, $width = null, $height = null)
{
$code = self::element('object', [
'width' => $width ?: 600,
'height' => $height ?: 400,
'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
'codebase' => 'http://download.macromedia.com... | [
"public",
"static",
"function",
"flash",
"(",
"$",
"src",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"$",
"code",
"=",
"self",
"::",
"element",
"(",
"'object'",
",",
"[",
"'width'",
"=>",
"$",
"width",
"?",
":",
"6... | Creates a flash element.
@param string $src The swf file source
@param null|int $width Width attribute
@param null|int $height Height attribute
@return string | [
"Creates",
"a",
"flash",
"element",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L146-L169 |
oscarotero/Embed | src/Utils.php | Utils.element | private static function element($name, array $attrs)
{
$str = "<$name";
foreach ($attrs as $name => $value) {
if ($value === null) {
continue;
} elseif ($value === true) {
$str .= " $name";
} elseif ($value !== false) {
... | php | private static function element($name, array $attrs)
{
$str = "<$name";
foreach ($attrs as $name => $value) {
if ($value === null) {
continue;
} elseif ($value === true) {
$str .= " $name";
} elseif ($value !== false) {
... | [
"private",
"static",
"function",
"element",
"(",
"$",
"name",
",",
"array",
"$",
"attrs",
")",
"{",
"$",
"str",
"=",
"\"<$name\"",
";",
"foreach",
"(",
"$",
"attrs",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
... | Creates an html element.
@param string $name Element name
@param array $attrs Element attributes
@return string | [
"Creates",
"an",
"html",
"element",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L179-L194 |
oscarotero/Embed | src/Utils.php | Utils.toUtf8 | public static function toUtf8($content, $charset)
{
$charset = strtoupper($charset);
if (empty($charset) || $charset === 'UTF-8') {
return $content;
}
$encodings = array_map('strtoupper', mb_list_encodings());
if (in_array($charset, $encodings, true)) {
... | php | public static function toUtf8($content, $charset)
{
$charset = strtoupper($charset);
if (empty($charset) || $charset === 'UTF-8') {
return $content;
}
$encodings = array_map('strtoupper', mb_list_encodings());
if (in_array($charset, $encodings, true)) {
... | [
"public",
"static",
"function",
"toUtf8",
"(",
"$",
"content",
",",
"$",
"charset",
")",
"{",
"$",
"charset",
"=",
"strtoupper",
"(",
"$",
"charset",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"charset",
")",
"||",
"$",
"charset",
"===",
"'UTF-8'",
")",... | Convert a string to utf-8.
@param string $content The content to convert
@param string $charset The original charset
@return string | [
"Convert",
"a",
"string",
"to",
"utf",
"-",
"8",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L204-L223 |
oscarotero/Embed | src/Utils.php | Utils.xpathQuery | public static function xpathQuery(DOMDocument $document, $query, $returnFirst = true)
{
$xpath = new DOMXPath($document);
$entries = $xpath->query($query);
if ($entries->length) {
return $returnFirst ? $entries->item(0) : $entries;
}
} | php | public static function xpathQuery(DOMDocument $document, $query, $returnFirst = true)
{
$xpath = new DOMXPath($document);
$entries = $xpath->query($query);
if ($entries->length) {
return $returnFirst ? $entries->item(0) : $entries;
}
} | [
"public",
"static",
"function",
"xpathQuery",
"(",
"DOMDocument",
"$",
"document",
",",
"$",
"query",
",",
"$",
"returnFirst",
"=",
"true",
")",
"{",
"$",
"xpath",
"=",
"new",
"DOMXPath",
"(",
"$",
"document",
")",
";",
"$",
"entries",
"=",
"$",
"xpath... | Search and return the first element matching with a xpath
@param DOMDocument $document
@param string $query
@param bool $returnFirst
@return DOMElement|DOMNodeList|null | [
"Search",
"and",
"return",
"the",
"first",
"element",
"matching",
"with",
"a",
"xpath"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Utils.php#L234-L242 |
oscarotero/Embed | src/Adapters/Cnn.php | Cnn.getCode | public function getCode()
{
$url = Url::create('https://fave.api.cnn.io/v1/fav/')
->withQueryParameters([
'video' => implode('/', $this->getResponse()->getUrl()->getSlicePath(1)),
'customer' => 'cnn',
'env' => 'prod'
]);
$this-... | php | public function getCode()
{
$url = Url::create('https://fave.api.cnn.io/v1/fav/')
->withQueryParameters([
'video' => implode('/', $this->getResponse()->getUrl()->getSlicePath(1)),
'customer' => 'cnn',
'env' => 'prod'
]);
$this-... | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"url",
"=",
"Url",
"::",
"create",
"(",
"'https://fave.api.cnn.io/v1/fav/'",
")",
"->",
"withQueryParameters",
"(",
"[",
"'video'",
"=>",
"implode",
"(",
"'/'",
",",
"$",
"this",
"->",
"getResponse",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Cnn.php#L27-L40 |
oscarotero/Embed | src/Providers/OEmbed/Tumblr.php | Tumblr.create | public static function create(Adapter $adapter)
{
$response = $adapter->getResponse();
if ($response->getStartingUrl()->match(static::$pattern)) {
return new static($response);
}
} | php | public static function create(Adapter $adapter)
{
$response = $adapter->getResponse();
if ($response->getStartingUrl()->match(static::$pattern)) {
return new static($response);
}
} | [
"public",
"static",
"function",
"create",
"(",
"Adapter",
"$",
"adapter",
")",
"{",
"$",
"response",
"=",
"$",
"adapter",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStartingUrl",
"(",
")",
"->",
"match",
"(",
"static",
":... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OEmbed/Tumblr.php#L20-L27 |
oscarotero/Embed | src/Providers/OEmbed/DOM.php | DOM.getEndPoint | public function getEndPoint()
{
$html = $this->response->getHtmlContent();
if ($html && ($url = self::getEndPointFromDom($html))) {
try {
$endPoint = $this->response->getUrl()->createAbsolute($url);
} catch (Exception $exception) {
return null... | php | public function getEndPoint()
{
$html = $this->response->getHtmlContent();
if ($html && ($url = self::getEndPointFromDom($html))) {
try {
$endPoint = $this->response->getUrl()->createAbsolute($url);
} catch (Exception $exception) {
return null... | [
"public",
"function",
"getEndPoint",
"(",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"response",
"->",
"getHtmlContent",
"(",
")",
";",
"if",
"(",
"$",
"html",
"&&",
"(",
"$",
"url",
"=",
"self",
"::",
"getEndPointFromDom",
"(",
"$",
"html",
")",... | Returns the oembed endPoint.
@return Url|null | [
"Returns",
"the",
"oembed",
"endPoint",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OEmbed/DOM.php#L45-L62 |
oscarotero/Embed | src/Providers/OEmbed/DOM.php | DOM.getEndPointFromDom | protected static function getEndPointFromDom(DOMDocument $html)
{
foreach (['link', 'meta'] as $tagName) {
foreach ($html->getElementsByTagName($tagName) as $link) {
$rel = trim(strtolower($link->getAttribute('rel')));
$href = $link->getAttribute('href');
... | php | protected static function getEndPointFromDom(DOMDocument $html)
{
foreach (['link', 'meta'] as $tagName) {
foreach ($html->getElementsByTagName($tagName) as $link) {
$rel = trim(strtolower($link->getAttribute('rel')));
$href = $link->getAttribute('href');
... | [
"protected",
"static",
"function",
"getEndPointFromDom",
"(",
"DOMDocument",
"$",
"html",
")",
"{",
"foreach",
"(",
"[",
"'link'",
",",
"'meta'",
"]",
"as",
"$",
"tagName",
")",
"{",
"foreach",
"(",
"$",
"html",
"->",
"getElementsByTagName",
"(",
"$",
"tag... | Extract oembed information from the <link rel="alternate"> elements
Note: Some sites use <meta rel="alternate"> instead.
@param DOMDocument $html
@return string|null | [
"Extract",
"oembed",
"information",
"from",
"the",
"<link",
"rel",
"=",
"alternate",
">",
"elements",
"Note",
":",
"Some",
"sites",
"use",
"<meta",
"rel",
"=",
"alternate",
">",
"instead",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OEmbed/DOM.php#L72-L94 |
oscarotero/Embed | src/Adapters/N500px.php | N500px.getCode | public function getCode()
{
$url = $this->getResponse()->getUrl();
if (is_numeric($url->getDirectoryPosition(1))) {
return Utils::iframe($url->withDirectoryPosition(2, 'embed.html'), $this->width, $this->height);
}
} | php | public function getCode()
{
$url = $this->getResponse()->getUrl();
if (is_numeric($url->getDirectoryPosition(1))) {
return Utils::iframe($url->withDirectoryPosition(2, 'embed.html'), $this->width, $this->height);
}
} | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"url",
"->",
"getDirectoryPosition",
"(",
"1",
")",
")",
")",
"{",
"retur... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/N500px.php#L26-L33 |
oscarotero/Embed | src/Providers/Linkpulse.php | Linkpulse.getUrl | public function getUrl()
{
$url = $this->normalizeUrl($this->bag->get('url'));
if ($url !== $this->adapter->getResponse()->getUrl()->getAbsolute('/')) {
return $url;
}
} | php | public function getUrl()
{
$url = $this->normalizeUrl($this->bag->get('url'));
if ($url !== $this->adapter->getResponse()->getUrl()->getAbsolute('/')) {
return $url;
}
} | [
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"normalizeUrl",
"(",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'url'",
")",
")",
";",
"if",
"(",
"$",
"url",
"!==",
"$",
"this",
"->",
"adapter",
"->",
"getResp... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Linkpulse.php#L66-L73 |
oscarotero/Embed | src/Providers/Api/GoogleMaps.php | GoogleMaps.getTitle | public function getTitle()
{
$url = $this->adapter->getResponse()->getUrl();
if ($this->mode === 'place') {
return $url->getDirectoryPosition(2);
}
if ($this->mode === 'dir') {
return $url->getDirectoryPosition(2).' / '.$url->getDirectoryPosition(3);
... | php | public function getTitle()
{
$url = $this->adapter->getResponse()->getUrl();
if ($this->mode === 'place') {
return $url->getDirectoryPosition(2);
}
if ($this->mode === 'dir') {
return $url->getDirectoryPosition(2).' / '.$url->getDirectoryPosition(3);
... | [
"public",
"function",
"getTitle",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"mode",
"===",
"'place'",
")",
"{",
"return",
"$",
"url",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/GoogleMaps.php#L50-L61 |
oscarotero/Embed | src/Providers/Api/GoogleMaps.php | GoogleMaps.getCode | public function getCode()
{
$url = $this->adapter->getResponse()->getUrl();
$key = $this->adapter->getConfig('google[key]');
if (empty($key)) {
return;
}
switch ($this->mode) {
case 'view':
$pos = self::getPosition($this->mode, $url);... | php | public function getCode()
{
$url = $this->adapter->getResponse()->getUrl();
$key = $this->adapter->getConfig('google[key]');
if (empty($key)) {
return;
}
switch ($this->mode) {
case 'view':
$pos = self::getPosition($this->mode, $url);... | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getConfig",
"(",
"'google[key]'",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/GoogleMaps.php#L74-L126 |
oscarotero/Embed | src/Providers/Api/GoogleMaps.php | GoogleMaps.getPosition | private static function getPosition($mode, Url $url)
{
// Set defaults
$position = [
'coordinates' => '',
'zoom' => '4',
'heading' => '0',
'pitch' => '0',
'fov' => '90'
];
if ($mode === 'view') {
$pos = explode(... | php | private static function getPosition($mode, Url $url)
{
// Set defaults
$position = [
'coordinates' => '',
'zoom' => '4',
'heading' => '0',
'pitch' => '0',
'fov' => '90'
];
if ($mode === 'view') {
$pos = explode(... | [
"private",
"static",
"function",
"getPosition",
"(",
"$",
"mode",
",",
"Url",
"$",
"url",
")",
"{",
"// Set defaults",
"$",
"position",
"=",
"[",
"'coordinates'",
"=>",
"''",
",",
"'zoom'",
"=>",
"'4'",
",",
"'heading'",
"=>",
"'0'",
",",
"'pitch'",
"=>"... | Returns parsed position data from url.
@param string $mode The url mode
@param Url $url
@return array | [
"Returns",
"parsed",
"position",
"data",
"from",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/GoogleMaps.php#L136-L166 |
oscarotero/Embed | src/Adapters/Lavozdegalicia.php | Lavozdegalicia.init | protected function init()
{
parent::init();
$url = $this->getResponse()->getStartingUrl();
$this->response = $this->getDispatcher()->dispatch($url->withQueryParameter('piano_d', '1'));
} | php | protected function init()
{
parent::init();
$url = $this->getResponse()->getStartingUrl();
$this->response = $this->getDispatcher()->dispatch($url->withQueryParameter('piano_d', '1'));
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getStartingUrl",
"(",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"getDi... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Lavozdegalicia.php#L25-L32 |
oscarotero/Embed | src/Http/Response.php | Response.getHtmlContent | public function getHtmlContent()
{
if ($this->htmlContent === null) {
try {
if (empty($content = $this->content)) {
return $this->htmlContent = false;
}
$errors = libxml_use_internal_errors(true);
$entities = li... | php | public function getHtmlContent()
{
if ($this->htmlContent === null) {
try {
if (empty($content = $this->content)) {
return $this->htmlContent = false;
}
$errors = libxml_use_internal_errors(true);
$entities = li... | [
"public",
"function",
"getHtmlContent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"htmlContent",
"===",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"content",
"=",
"$",
"this",
"->",
"content",
")",
")",
"{",
"return",
"$",
"this... | Get the content as HTML.
@return DOMDocument|false | [
"Get",
"the",
"content",
"as",
"HTML",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Response.php#L52-L90 |
oscarotero/Embed | src/Http/Response.php | Response.getJsonContent | public function getJsonContent()
{
if ($this->jsonContent === null) {
try {
if (($content = $this->content) === '') {
return $this->jsonContent = false;
}
$this->jsonContent = json_decode($content, true);
} catch (\... | php | public function getJsonContent()
{
if ($this->jsonContent === null) {
try {
if (($content = $this->content) === '') {
return $this->jsonContent = false;
}
$this->jsonContent = json_decode($content, true);
} catch (\... | [
"public",
"function",
"getJsonContent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"jsonContent",
"===",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"$",
"content",
"=",
"$",
"this",
"->",
"content",
")",
"===",
"''",
")",
"{",
"return",
"$",
... | Get the content as an array from JSON.
@return array|false | [
"Get",
"the",
"content",
"as",
"an",
"array",
"from",
"JSON",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Response.php#L97-L112 |
oscarotero/Embed | src/Http/Response.php | Response.getXMLContent | public function getXMLContent()
{
if ($this->xmlContent === null) {
try {
if (($content = $this->content) === '') {
return $this->xmlContent = false;
}
$errors = libxml_use_internal_errors(true);
$this->xmlConte... | php | public function getXMLContent()
{
if ($this->xmlContent === null) {
try {
if (($content = $this->content) === '') {
return $this->xmlContent = false;
}
$errors = libxml_use_internal_errors(true);
$this->xmlConte... | [
"public",
"function",
"getXMLContent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"xmlContent",
"===",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"$",
"content",
"=",
"$",
"this",
"->",
"content",
")",
"===",
"''",
")",
"{",
"return",
"$",
"... | Get the content as XML.
@return SimpleXMLElement|false | [
"Get",
"the",
"content",
"as",
"XML",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Response.php#L119-L136 |
oscarotero/Embed | src/Http/Response.php | Response.setContent | private function setContent($content)
{
$this->content = $content;
if (empty($this->contentType)) {
return;
}
//Remove charset from Content-Type
if (strpos($this->contentType, ';') !== false) {
list($mime, $charset) = array_map('trim', explode(';', $... | php | private function setContent($content)
{
$this->content = $content;
if (empty($this->contentType)) {
return;
}
//Remove charset from Content-Type
if (strpos($this->contentType, ';') !== false) {
list($mime, $charset) = array_map('trim', explode(';', $... | [
"private",
"function",
"setContent",
"(",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"$",
"content",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"contentType",
")",
")",
"{",
"return",
";",
"}",
"//Remove charset from Content-Type",
... | Set the response content.
@param string $content | [
"Set",
"the",
"response",
"content",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Response.php#L143-L159 |
oscarotero/Embed | src/Adapters/Howcast.php | Howcast.getCode | public function getCode()
{
$this->width = null;
$this->height = null;
if (!($dom = $this->getResponse()->getHtmlContent())) {
return;
}
// #embedModal textarea
$textarea = Utils::xpathQuery($dom, "descendant-or-self::*[@id = 'embedModal']/descendant-or-... | php | public function getCode()
{
$this->width = null;
$this->height = null;
if (!($dom = $this->getResponse()->getHtmlContent())) {
return;
}
// #embedModal textarea
$textarea = Utils::xpathQuery($dom, "descendant-or-self::*[@id = 'embedModal']/descendant-or-... | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"this",
"->",
"width",
"=",
"null",
";",
"$",
"this",
"->",
"height",
"=",
"null",
";",
"if",
"(",
"!",
"(",
"$",
"dom",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getHtmlContent",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Howcast.php#L26-L41 |
oscarotero/Embed | src/Http/Url.php | Url.match | public function match($patterns)
{
if (!is_array($patterns)) {
$patterns = [$patterns];
}
//Remove scheme and query
$long_url = preg_replace('|^(\w+://)|', '', (string) $this);
$short_url = preg_replace('|(\?.*)?$|', '', $long_url);
foreach ($patterns as... | php | public function match($patterns)
{
if (!is_array($patterns)) {
$patterns = [$patterns];
}
//Remove scheme and query
$long_url = preg_replace('|^(\w+://)|', '', (string) $this);
$short_url = preg_replace('|(\?.*)?$|', '', $long_url);
foreach ($patterns as... | [
"public",
"function",
"match",
"(",
"$",
"patterns",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"patterns",
")",
")",
"{",
"$",
"patterns",
"=",
"[",
"$",
"patterns",
"]",
";",
"}",
"//Remove scheme and query",
"$",
"long_url",
"=",
"preg_replace",
... | Check if the url match with a specific pattern. The patterns only accepts * and ?
@param string|array $patterns The pattern or an array with various patterns
@return bool | [
"Check",
"if",
"the",
"url",
"match",
"with",
"a",
"specific",
"pattern",
".",
"The",
"patterns",
"only",
"accepts",
"*",
"and",
"?"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L65-L95 |
oscarotero/Embed | src/Http/Url.php | Url.withExtension | public function withExtension($extension)
{
$clone = clone $this;
$clone->info['extension'] = $extension;
if (empty($clone->info['file'])) {
$clone->info['file'] = array_pop($clone->info['path']);
}
return $clone;
} | php | public function withExtension($extension)
{
$clone = clone $this;
$clone->info['extension'] = $extension;
if (empty($clone->info['file'])) {
$clone->info['file'] = array_pop($clone->info['path']);
}
return $clone;
} | [
"public",
"function",
"withExtension",
"(",
"$",
"extension",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"info",
"[",
"'extension'",
"]",
"=",
"$",
"extension",
";",
"if",
"(",
"empty",
"(",
"$",
"clone",
"->",
"info"... | Returns a clone with other extension.
@param string $extension
@return Url | [
"Returns",
"a",
"clone",
"with",
"other",
"extension",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L136-L146 |
oscarotero/Embed | src/Http/Url.php | Url.getDomain | public function getDomain($first_level = false)
{
$host = $this->getHost();
if (empty($host)) {
return '';
}
$host = array_reverse(explode('.', $host));
switch (count($host)) {
case 1:
return $host[0];
case 2:
... | php | public function getDomain($first_level = false)
{
$host = $this->getHost();
if (empty($host)) {
return '';
}
$host = array_reverse(explode('.', $host));
switch (count($host)) {
case 1:
return $host[0];
case 2:
... | [
"public",
"function",
"getDomain",
"(",
"$",
"first_level",
"=",
"false",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"getHost",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"host",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"host",
"=",
... | Return the domain of the url (for example: google).
@param bool $first_level True to return the first level domain (.com, .es, etc)
@return string | [
"Return",
"the",
"domain",
"of",
"the",
"url",
"(",
"for",
"example",
":",
"google",
")",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L205-L232 |
oscarotero/Embed | src/Http/Url.php | Url.getDirectoryPosition | public function getDirectoryPosition($position)
{
if ($position === count($this->info['path'])) {
return urldecode($this->info['file']);
}
return isset($this->info['path'][$position]) ? urldecode($this->info['path'][$position]) : null;
} | php | public function getDirectoryPosition($position)
{
if ($position === count($this->info['path'])) {
return urldecode($this->info['file']);
}
return isset($this->info['path'][$position]) ? urldecode($this->info['path'][$position]) : null;
} | [
"public",
"function",
"getDirectoryPosition",
"(",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"position",
"===",
"count",
"(",
"$",
"this",
"->",
"info",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
"urldecode",
"(",
"$",
"this",
"->",
"info",
"[",
"... | Return a specific directory position in the path of the url.
@param int $position The position of the directory (0 based index)
@return string|null | [
"Return",
"a",
"specific",
"directory",
"position",
"in",
"the",
"path",
"of",
"the",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L241-L248 |
oscarotero/Embed | src/Http/Url.php | Url.withDirectoryPosition | public function withDirectoryPosition($key, $value)
{
$clone = clone $this;
$pos = $clone->info['path'];
$hasFile = isset($clone->info['file']);
if ($hasFile) {
$pos[] = $clone->info['file'];
}
$pos[$key] = $value;
if ($hasFile) {
$... | php | public function withDirectoryPosition($key, $value)
{
$clone = clone $this;
$pos = $clone->info['path'];
$hasFile = isset($clone->info['file']);
if ($hasFile) {
$pos[] = $clone->info['file'];
}
$pos[$key] = $value;
if ($hasFile) {
$... | [
"public",
"function",
"withDirectoryPosition",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"pos",
"=",
"$",
"clone",
"->",
"info",
"[",
"'path'",
"]",
";",
"$",
"hasFile",
"=",
"isset",
"(",
"$",... | Returns a clone with other directory in a specific position.
@param int|null $key The position of the subdirectory (0 based index)
@param string $value The new value
@return Url | [
"Returns",
"a",
"clone",
"with",
"other",
"directory",
"in",
"a",
"specific",
"position",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L258-L278 |
oscarotero/Embed | src/Http/Url.php | Url.getSlicePath | public function getSlicePath($offset, $length = null)
{
$array = explode('/', $this->getPath());
if (empty($array[0])) {
array_shift($array);
}
return array_slice($array, $offset, $length);
} | php | public function getSlicePath($offset, $length = null)
{
$array = explode('/', $this->getPath());
if (empty($array[0])) {
array_shift($array);
}
return array_slice($array, $offset, $length);
} | [
"public",
"function",
"getSlicePath",
"(",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"array",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"array",
"[",
"0",... | Slice path.
@param int $offset
@param int|null $length
@return array | [
"Slice",
"path",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L298-L307 |
oscarotero/Embed | src/Http/Url.php | Url.getPath | public function getPath()
{
$path = !empty($this->info['path']) ? '/'.implode('/', array_map('self::urlEncode', $this->info['path'])).'/' : '/';
if (isset($this->info['file'])) {
$path .= self::urlEncode($this->info['file']);
if (isset($this->info['extension'])) {
... | php | public function getPath()
{
$path = !empty($this->info['path']) ? '/'.implode('/', array_map('self::urlEncode', $this->info['path'])).'/' : '/';
if (isset($this->info['file'])) {
$path .= self::urlEncode($this->info['file']);
if (isset($this->info['extension'])) {
... | [
"public",
"function",
"getPath",
"(",
")",
"{",
"$",
"path",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"info",
"[",
"'path'",
"]",
")",
"?",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"array_map",
"(",
"'self::urlEncode'",
",",
"$",
"this",
"->",
"in... | Return the url path.
@return string | [
"Return",
"the",
"url",
"path",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L314-L327 |
oscarotero/Embed | src/Http/Url.php | Url.getQueryParameter | public function getQueryParameter($name)
{
return isset($this->info['query'][$name]) ? $this->info['query'][$name] : null;
} | php | public function getQueryParameter($name)
{
return isset($this->info['query'][$name]) ? $this->info['query'][$name] : null;
} | [
"public",
"function",
"getQueryParameter",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"'query'",
"]",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"info",
"[",
"'query'",
"]",
"[",
"$",
"name",
"]",
... | Returns a query parameter value.
@param string $name
@return string|null | [
"Returns",
"a",
"query",
"parameter",
"value",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L388-L391 |
oscarotero/Embed | src/Http/Url.php | Url.withAddedQueryParameters | public function withAddedQueryParameters(array $parameters)
{
$clone = clone $this;
$clone->info['query'] = empty($clone->info['query']) ? $parameters : array_replace($clone->info['query'], $parameters);
return $clone;
} | php | public function withAddedQueryParameters(array $parameters)
{
$clone = clone $this;
$clone->info['query'] = empty($clone->info['query']) ? $parameters : array_replace($clone->info['query'], $parameters);
return $clone;
} | [
"public",
"function",
"withAddedQueryParameters",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"info",
"[",
"'query'",
"]",
"=",
"empty",
"(",
"$",
"clone",
"->",
"info",
"[",
"'query'",
"... | Returns a clone with new query parameters merged.
@param array $parameters
@return Url | [
"Returns",
"a",
"clone",
"with",
"new",
"query",
"parameters",
"merged",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L417-L424 |
oscarotero/Embed | src/Http/Url.php | Url.getClassNameForDomain | public function getClassNameForDomain()
{
$className = str_replace(array('-', ' '), '', ucwords(strtolower($this->getDomain())));
if (is_numeric(mb_substr($className, 0, 1))) {
$className = 'N'.$className;
}
return $className;
} | php | public function getClassNameForDomain()
{
$className = str_replace(array('-', ' '), '', ucwords(strtolower($this->getDomain())));
if (is_numeric(mb_substr($className, 0, 1))) {
$className = 'N'.$className;
}
return $className;
} | [
"public",
"function",
"getClassNameForDomain",
"(",
")",
"{",
"$",
"className",
"=",
"str_replace",
"(",
"array",
"(",
"'-'",
",",
"' '",
")",
",",
"''",
",",
"ucwords",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"getDomain",
"(",
")",
")",
")",
")",
... | Return ClassName for domain.
Domains started with numbers will get N prepended to their class name.
@return string | [
"Return",
"ClassName",
"for",
"domain",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L459-L468 |
oscarotero/Embed | src/Http/Url.php | Url.buildUrl | protected function buildUrl()
{
$url = '';
if (isset($this->info['content'])) {
return 'data:'.$this->info['content'];
}
if (isset($this->info['scheme'])) {
$url .= $this->info['scheme'].'://';
}
$user = isset($this->info['user']) ? $this->i... | php | protected function buildUrl()
{
$url = '';
if (isset($this->info['content'])) {
return 'data:'.$this->info['content'];
}
if (isset($this->info['scheme'])) {
$url .= $this->info['scheme'].'://';
}
$user = isset($this->info['user']) ? $this->i... | [
"protected",
"function",
"buildUrl",
"(",
")",
"{",
"$",
"url",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"'content'",
"]",
")",
")",
"{",
"return",
"'data:'",
".",
"$",
"this",
"->",
"info",
"[",
"'content'",
"]",
... | Build the url using the splitted data. | [
"Build",
"the",
"url",
"using",
"the",
"splitted",
"data",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L473-L509 |
oscarotero/Embed | src/Http/Url.php | Url.parseUrl | protected function parseUrl($url)
{
$this->info = self::parse($url);
if (isset($this->info['path'])) {
$this->setPath($this->info['path']);
}
if (empty($this->info['query'])) {
$this->info['query'] = [];
return;
}
// Fix dots an... | php | protected function parseUrl($url)
{
$this->info = self::parse($url);
if (isset($this->info['path'])) {
$this->setPath($this->info['path']);
}
if (empty($this->info['query'])) {
$this->info['query'] = [];
return;
}
// Fix dots an... | [
"protected",
"function",
"parseUrl",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"info",
"=",
"self",
"::",
"parse",
"(",
"$",
"url",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"this"... | Parse an url and split into different pieces.
@param string $url The url to parse | [
"Parse",
"an",
"url",
"and",
"split",
"into",
"different",
"pieces",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L516-L543 |
oscarotero/Embed | src/Http/Url.php | Url.getAbsolute | public function getAbsolute($url)
{
$url = trim($url);
if (empty($url)) {
return '';
}
if (preg_match('|^\w+:[^/]|', $url)) {
return $url;
}
if (preg_match('|^\w+://|', $url)) {
return self::validUrlOrEmpty($url);
}
... | php | public function getAbsolute($url)
{
$url = trim($url);
if (empty($url)) {
return '';
}
if (preg_match('|^\w+:[^/]|', $url)) {
return $url;
}
if (preg_match('|^\w+://|', $url)) {
return self::validUrlOrEmpty($url);
}
... | [
"public",
"function",
"getAbsolute",
"(",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'|^\\w+:[^/]|'",
",",... | Return an absolute url based in a relative.
@return string | [
"Return",
"an",
"absolute",
"url",
"based",
"in",
"a",
"relative",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L550-L579 |
oscarotero/Embed | src/Http/Url.php | Url.setPath | private function setPath($path)
{
$this->info['path'] = $this->info['file'] = $this->info['extension'] = $this->info['content'] = null;
if ($this->getScheme() === 'data') {
$this->info['content'] = $path;
return;
}
$file = substr(strrchr($path, '/'), 1);
... | php | private function setPath($path)
{
$this->info['path'] = $this->info['file'] = $this->info['extension'] = $this->info['content'] = null;
if ($this->getScheme() === 'data') {
$this->info['content'] = $path;
return;
}
$file = substr(strrchr($path, '/'), 1);
... | [
"private",
"function",
"setPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"info",
"[",
"'path'",
"]",
"=",
"$",
"this",
"->",
"info",
"[",
"'file'",
"]",
"=",
"$",
"this",
"->",
"info",
"[",
"'extension'",
"]",
"=",
"$",
"this",
"->",
"inf... | Parses and adds path and file value.
@param string $path | [
"Parses",
"and",
"adds",
"path",
"and",
"file",
"value",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L586-L618 |
oscarotero/Embed | src/Http/Url.php | Url.parse | private static function parse($url)
{
$enc_url = preg_replace_callback(
'%[^:/@?&=#]+%usD',
function ($matches) {
return rawurlencode($matches[0]);
},
$url
);
$parts = parse_url($enc_url);
if ($parts === false) {
... | php | private static function parse($url)
{
$enc_url = preg_replace_callback(
'%[^:/@?&=#]+%usD',
function ($matches) {
return rawurlencode($matches[0]);
},
$url
);
$parts = parse_url($enc_url);
if ($parts === false) {
... | [
"private",
"static",
"function",
"parse",
"(",
"$",
"url",
")",
"{",
"$",
"enc_url",
"=",
"preg_replace_callback",
"(",
"'%[^:/@?&=#]+%usD'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"rawurlencode",
"(",
"$",
"matches",
"[",
"0",
"]",
")",... | UTF-8 compatible parse_url
http://php.net/manual/en/function.parse-url.php#114817
@param string $url
@return string | [
"UTF",
"-",
"8",
"compatible",
"parse_url",
"http",
":",
"//",
"php",
".",
"net",
"/",
"manual",
"/",
"en",
"/",
"function",
".",
"parse",
"-",
"url",
".",
"php#114817"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Url.php#L637-L661 |
oscarotero/Embed | src/Adapters/Webpage.php | Webpage.init | protected function init()
{
$this->providers = [
'oembed' => new Providers\OEmbed($this),
'opengraph' => new Providers\OpenGraph($this),
'linkpulse' => new Providers\Linkpulse($this),
'twittercards' => new Providers\TwitterCards($this),
'dcterms' =... | php | protected function init()
{
$this->providers = [
'oembed' => new Providers\OEmbed($this),
'opengraph' => new Providers\OpenGraph($this),
'linkpulse' => new Providers\Linkpulse($this),
'twittercards' => new Providers\TwitterCards($this),
'dcterms' =... | [
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"providers",
"=",
"[",
"'oembed'",
"=>",
"new",
"Providers",
"\\",
"OEmbed",
"(",
"$",
"this",
")",
",",
"'opengraph'",
"=>",
"new",
"Providers",
"\\",
"OpenGraph",
"(",
"$",
"this",
")... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Webpage.php#L15-L26 |
oscarotero/Embed | src/Http/ImageResponse.php | ImageResponse.createFromBase64 | public static function createFromBase64(Url $url)
{
$pieces = explode(';', $url->getContent(), 2);
if ((count($pieces) !== 2) || (strpos($pieces[0], 'image/') === false) || (strpos($pieces[1], 'base64,') !== 0)) {
return false;
}
if (($info = @getimagesizefromstring(bas... | php | public static function createFromBase64(Url $url)
{
$pieces = explode(';', $url->getContent(), 2);
if ((count($pieces) !== 2) || (strpos($pieces[0], 'image/') === false) || (strpos($pieces[1], 'base64,') !== 0)) {
return false;
}
if (($info = @getimagesizefromstring(bas... | [
"public",
"static",
"function",
"createFromBase64",
"(",
"Url",
"$",
"url",
")",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"';'",
",",
"$",
"url",
"->",
"getContent",
"(",
")",
",",
"2",
")",
";",
"if",
"(",
"(",
"count",
"(",
"$",
"pieces",
")",
... | Create a ImageResponse using a bas64 url.
@param Url $url
@return static|null | [
"Create",
"a",
"ImageResponse",
"using",
"a",
"bas64",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/ImageResponse.php#L19-L38 |
oscarotero/Embed | src/Bag.php | Bag.set | public function set($name, $value = null)
{
if (!is_array($name)) {
$name = [$name => $value];
}
foreach ($name as $name => $value) {
$name = self::normalizeName($name);
$value = self::normalizeValue($value);
$this->parameters[$name] = $value... | php | public function set($name, $value = null)
{
if (!is_array($name)) {
$name = [$name => $value];
}
foreach ($name as $name => $value) {
$name = self::normalizeName($name);
$value = self::normalizeValue($value);
$this->parameters[$name] = $value... | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"[",
"$",
"name",
"=>",
"$",
"value",
"]",
";",
"}",
"foreach",
"(",
"$",
... | Save a value.
@param string|array $name
@param mixed $value | [
"Save",
"a",
"value",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Bag.php#L28-L40 |
oscarotero/Embed | src/Bag.php | Bag.add | public function add($name, $value = null)
{
$name = self::normalizeName($name);
$value = self::normalizeValue($value);
if (!isset($this->parameters[$name])) {
$this->parameters[$name] = [];
} elseif (!is_array($this->parameters[$name])) {
$this->parameters[$n... | php | public function add($name, $value = null)
{
$name = self::normalizeName($name);
$value = self::normalizeValue($value);
if (!isset($this->parameters[$name])) {
$this->parameters[$name] = [];
} elseif (!is_array($this->parameters[$name])) {
$this->parameters[$n... | [
"public",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"normalizeName",
"(",
"$",
"name",
")",
";",
"$",
"value",
"=",
"self",
"::",
"normalizeValue",
"(",
"$",
"value",
")",
";",
... | Adds a subvalue.
@param string $name
@param mixed $value | [
"Adds",
"a",
"subvalue",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Bag.php#L48-L60 |
oscarotero/Embed | src/Bag.php | Bag.get | public function get($name, $isHtml = false)
{
$name = self::normalizeName($name);
if (strpos($name, '[') !== false) {
$names = explode('[', str_replace(']', '', $name));
$key = array_shift($names);
$item = isset($this->parameters[$key]) ? $this->parameters[$key] ... | php | public function get($name, $isHtml = false)
{
$name = self::normalizeName($name);
if (strpos($name, '[') !== false) {
$names = explode('[', str_replace(']', '', $name));
$key = array_shift($names);
$item = isset($this->parameters[$key]) ? $this->parameters[$key] ... | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"isHtml",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"normalizeName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'['",
")",
"!==",
"false",
")",
... | Get a value.
@param string $name
@param bool $isHtml
@return string|null | [
"Get",
"a",
"value",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Bag.php#L70-L93 |
oscarotero/Embed | src/Bag.php | Bag.has | public function has($name)
{
$name = self::normalizeName($name);
if (strpos($name, '[') !== false) {
$names = explode('[', str_replace(']', '', $name));
$key = array_shift($names);
$item = isset($this->parameters[$key]) ? $this->parameters[$key] : [];
... | php | public function has($name)
{
$name = self::normalizeName($name);
if (strpos($name, '[') !== false) {
$names = explode('[', str_replace(']', '', $name));
$key = array_shift($names);
$item = isset($this->parameters[$key]) ? $this->parameters[$key] : [];
... | [
"public",
"function",
"has",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"normalizeName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'['",
")",
"!==",
"false",
")",
"{",
"$",
"names",
"=",
"explode",
... | Check if a value exists and is not empty.
@param string $name
@return bool | [
"Check",
"if",
"a",
"value",
"exists",
"and",
"is",
"not",
"empty",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Bag.php#L122-L143 |
oscarotero/Embed | src/Bag.php | Bag.normalizeValue | private static function normalizeValue($value)
{
if (is_string($value)) {
$value = str_ireplace([' ', ' '], ' ', $value);
$value = trim($value);
return ($value === '') ? null : $value;
}
return $value;
} | php | private static function normalizeValue($value)
{
if (is_string($value)) {
$value = str_ireplace([' ', ' '], ' ', $value);
$value = trim($value);
return ($value === '') ? null : $value;
}
return $value;
} | [
"private",
"static",
"function",
"normalizeValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"str_ireplace",
"(",
"[",
"' '",
",",
"' '",
"]",
",",
"' '",
",",
"$",
"value",
")... | Normalize a value.
If it's a string, removes spaces and normalize some utf-8 chars.
@param mixed $value
@return mixed | [
"Normalize",
"a",
"value",
".",
"If",
"it",
"s",
"a",
"string",
"removes",
"spaces",
"and",
"normalize",
"some",
"utf",
"-",
"8",
"chars",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Bag.php#L165-L175 |
oscarotero/Embed | src/Bag.php | Bag.toPlainValue | private static function toPlainValue($value)
{
if (is_string($value)) {
$value = strip_tags($value);
$value = html_entity_decode($value, ENT_QUOTES | ENT_XML1, 'UTF-8');
$value = trim($value);
return ($value === '') ? null : $value;
}
return ... | php | private static function toPlainValue($value)
{
if (is_string($value)) {
$value = strip_tags($value);
$value = html_entity_decode($value, ENT_QUOTES | ENT_XML1, 'UTF-8');
$value = trim($value);
return ($value === '') ? null : $value;
}
return ... | [
"private",
"static",
"function",
"toPlainValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"strip_tags",
"(",
"$",
"value",
")",
";",
"$",
"value",
"=",
"html_entity_decode",
"(",
"$",
"... | Remove the html code and entities in a value
@param mixed $value
@return mixed | [
"Remove",
"the",
"html",
"code",
"and",
"entities",
"in",
"a",
"value"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Bag.php#L184-L195 |
oscarotero/Embed | src/Providers/Api/Gist.php | Gist.getCode | public function getCode()
{
if (($code = $this->bag->get('div', true)) && ($stylesheet = $this->normalizeUrl($this->bag->get('stylesheet')))) {
return '<link href="'.$stylesheet.'" rel="stylesheet">'.$code;
}
} | php | public function getCode()
{
if (($code = $this->bag->get('div', true)) && ($stylesheet = $this->normalizeUrl($this->bag->get('stylesheet')))) {
return '<link href="'.$stylesheet.'" rel="stylesheet">'.$code;
}
} | [
"public",
"function",
"getCode",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"code",
"=",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'div'",
",",
"true",
")",
")",
"&&",
"(",
"$",
"stylesheet",
"=",
"$",
"this",
"->",
"normalizeUrl",
"(",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/Gist.php#L65-L70 |
oscarotero/Embed | src/Providers/OpenGraph.php | OpenGraph.getType | public function getType()
{
$type = $this->bag->get('type');
if (strpos($type, ':') !== false) {
$type = substr(strrchr($type, ':'), 1);
}
switch ($type) {
case 'video':
case 'photo':
case 'link':
case 'rich':
... | php | public function getType()
{
$type = $this->bag->get('type');
if (strpos($type, ':') !== false) {
$type = substr(strrchr($type, ':'), 1);
}
switch ($type) {
case 'video':
case 'photo':
case 'link':
case 'rich':
... | [
"public",
"function",
"getType",
"(",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'type'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"type",
",",
"':'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"substr",
"(",... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OpenGraph.php#L88-L110 |
oscarotero/Embed | src/Providers/OpenGraph.php | OpenGraph.getCode | public function getCode()
{
$names = ['video:secure_url', 'video:url', 'video'];
foreach ($names as $name) {
if ($this->bag->has($name)) {
$video = $this->normalizeUrl($this->bag->get($name));
if (!($videoPath = parse_url($video, PHP_URL_PATH)) || !($typ... | php | public function getCode()
{
$names = ['video:secure_url', 'video:url', 'video'];
foreach ($names as $name) {
if ($this->bag->has($name)) {
$video = $this->normalizeUrl($this->bag->get($name));
if (!($videoPath = parse_url($video, PHP_URL_PATH)) || !($typ... | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"names",
"=",
"[",
"'video:secure_url'",
",",
"'video:url'",
",",
"'video'",
"]",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"bag",
"->",
"has",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OpenGraph.php#L115-L150 |
oscarotero/Embed | src/Providers/OpenGraph.php | OpenGraph.getPublishedTime | public function getPublishedTime()
{
return $this->bag->get('article:published_time')
?: $this->bag->get('article:modified_time')
?: $this->bag->get('video:release_date')
?: $this->bag->get('music:release_date');
} | php | public function getPublishedTime()
{
return $this->bag->get('article:published_time')
?: $this->bag->get('article:modified_time')
?: $this->bag->get('video:release_date')
?: $this->bag->get('music:release_date');
} | [
"public",
"function",
"getPublishedTime",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'article:published_time'",
")",
"?",
":",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'article:modified_time'",
")",
"?",
":",
"$",
"this",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OpenGraph.php#L211-L217 |
oscarotero/Embed | src/Providers/Api/Facebook.php | Facebook.getImagesUrls | public function getImagesUrls()
{
$images = (array) $this->bag->get('cover[source]');
if (($id = $this->bag->get('id'))) {
$images[] = 'https://graph.facebook.com/'.$id.'/picture';
}
return $this->normalizeUrls($images);
} | php | public function getImagesUrls()
{
$images = (array) $this->bag->get('cover[source]');
if (($id = $this->bag->get('id'))) {
$images[] = 'https://graph.facebook.com/'.$id.'/picture';
}
return $this->normalizeUrls($images);
} | [
"public",
"function",
"getImagesUrls",
"(",
")",
"{",
"$",
"images",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'cover[source]'",
")",
";",
"if",
"(",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'id... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/Facebook.php#L73-L82 |
oscarotero/Embed | src/Providers/Api/Facebook.php | Facebook.getEndPoint | private function getEndPoint()
{
$url = $this->adapter->getResponse()->getUrl();
$key = $this->adapter->getConfig('facebook[key]');
if (empty($key)) {
return;
}
if ($url->getDirectoryPosition(0) === 'events') {
return Url::create('https://graph.face... | php | private function getEndPoint()
{
$url = $this->adapter->getResponse()->getUrl();
$key = $this->adapter->getConfig('facebook[key]');
if (empty($key)) {
return;
}
if ($url->getDirectoryPosition(0) === 'events') {
return Url::create('https://graph.face... | [
"private",
"function",
"getEndPoint",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getConfig",
"(",
"'facebook[key]'",
... | Returns the Graph API Endpoint
@return Url|null | [
"Returns",
"the",
"Graph",
"API",
"Endpoint"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/Facebook.php#L105-L127 |
oscarotero/Embed | src/Providers/Api/Archive.php | Archive.getImagesUrls | public function getImagesUrls()
{
$images = (array) $this->bag->get('misc[image]');
foreach (array_keys((array) $this->bag->get('files')) as $url) {
$images[] = $url;
}
return $this->normalizeUrls($images);
} | php | public function getImagesUrls()
{
$images = (array) $this->bag->get('misc[image]');
foreach (array_keys((array) $this->bag->get('files')) as $url) {
$images[] = $url;
}
return $this->normalizeUrls($images);
} | [
"public",
"function",
"getImagesUrls",
"(",
")",
"{",
"$",
"images",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'misc[image]'",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"bag",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/Archive.php#L88-L97 |
oscarotero/Embed | src/Providers/Api/Soundcloud.php | Soundcloud.getImagesUrls | public function getImagesUrls()
{
$images = [];
if (empty($this->bag->get('artwork_url')) && ($img = $this->bag->get('user[avatar_url]'))) {
$images[] = str_replace('-large.jpg', '-t500x500.jpg', $img);
}
return $this->normalizeUrls($images);
} | php | public function getImagesUrls()
{
$images = [];
if (empty($this->bag->get('artwork_url')) && ($img = $this->bag->get('user[avatar_url]'))) {
$images[] = str_replace('-large.jpg', '-t500x500.jpg', $img);
}
return $this->normalizeUrls($images);
} | [
"public",
"function",
"getImagesUrls",
"(",
")",
"{",
"$",
"images",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'artwork_url'",
")",
")",
"&&",
"(",
"$",
"img",
"=",
"$",
"this",
"->",
"bag",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Api/Soundcloud.php#L65-L74 |
oscarotero/Embed | src/Providers/Sailthru.php | Sailthru.getImagesUrls | public function getImagesUrls()
{
$images = [];
foreach ($this->bag->getKeys() as $name) {
if (strpos($name, 'image') !== false) {
$images[] = $this->bag->get($name);
}
}
return $this->normalizeUrls($images);
} | php | public function getImagesUrls()
{
$images = [];
foreach ($this->bag->getKeys() as $name) {
if (strpos($name, 'image') !== false) {
$images[] = $this->bag->get($name);
}
}
return $this->normalizeUrls($images);
} | [
"public",
"function",
"getImagesUrls",
"(",
")",
"{",
"$",
"images",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"bag",
"->",
"getKeys",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'image'",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Sailthru.php#L40-L51 |
oscarotero/Embed | src/Adapters/Slides.php | Slides.getCode | public function getCode()
{
return Utils::iframe($this->getResponse()->getUrl()->withAddedPath('embed'), $this->width, $this->height);
} | php | public function getCode()
{
return Utils::iframe($this->getResponse()->getUrl()->withAddedPath('embed'), $this->width, $this->height);
} | [
"public",
"function",
"getCode",
"(",
")",
"{",
"return",
"Utils",
"::",
"iframe",
"(",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
"->",
"withAddedPath",
"(",
"'embed'",
")",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Slides.php#L26-L29 |
oscarotero/Embed | src/Http/Redirects.php | Redirects.resolve | public static function resolve(Url $url)
{
foreach (self::$patterns as $method => $pattern) {
if ($url->match($pattern)) {
return self::$method($url);
}
}
return $url;
} | php | public static function resolve(Url $url)
{
foreach (self::$patterns as $method => $pattern) {
if ($url->match($pattern)) {
return self::$method($url);
}
}
return $url;
} | [
"public",
"static",
"function",
"resolve",
"(",
"Url",
"$",
"url",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"patterns",
"as",
"$",
"method",
"=>",
"$",
"pattern",
")",
"{",
"if",
"(",
"$",
"url",
"->",
"match",
"(",
"$",
"pattern",
")",
")",
... | Resolve the url redirection.
@param Url $url
@return Url | [
"Resolve",
"the",
"url",
"redirection",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Redirects.php#L25-L34 |
oscarotero/Embed | src/Http/Redirects.php | Redirects.google | public static function google(Url $url)
{
if (($value = $url->getQueryParameter('url'))) {
return Url::create($value);
}
return $url;
} | php | public static function google(Url $url)
{
if (($value = $url->getQueryParameter('url'))) {
return Url::create($value);
}
return $url;
} | [
"public",
"static",
"function",
"google",
"(",
"Url",
"$",
"url",
")",
"{",
"if",
"(",
"(",
"$",
"value",
"=",
"$",
"url",
"->",
"getQueryParameter",
"(",
"'url'",
")",
")",
")",
"{",
"return",
"Url",
"::",
"create",
"(",
"$",
"value",
")",
";",
... | Resolve a google redirection url.
@param Url $url
@return Url | [
"Resolve",
"a",
"google",
"redirection",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Redirects.php#L43-L50 |
oscarotero/Embed | src/Http/Redirects.php | Redirects.googleTranslator | public static function googleTranslator(Url $url)
{
if (($value = $url->getQueryParameter('u'))) {
return Url::create($value);
}
return $url;
} | php | public static function googleTranslator(Url $url)
{
if (($value = $url->getQueryParameter('u'))) {
return Url::create($value);
}
return $url;
} | [
"public",
"static",
"function",
"googleTranslator",
"(",
"Url",
"$",
"url",
")",
"{",
"if",
"(",
"(",
"$",
"value",
"=",
"$",
"url",
"->",
"getQueryParameter",
"(",
"'u'",
")",
")",
")",
"{",
"return",
"Url",
"::",
"create",
"(",
"$",
"value",
")",
... | Resolve a google translation url.
@param Url $url
@return Url | [
"Resolve",
"a",
"google",
"translation",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Redirects.php#L59-L66 |
oscarotero/Embed | src/Http/Redirects.php | Redirects.tumblr | public static function tumblr(Url $url)
{
if (($value = $url->getQueryParameter('z'))) {
return Url::create($value);
}
return $url;
} | php | public static function tumblr(Url $url)
{
if (($value = $url->getQueryParameter('z'))) {
return Url::create($value);
}
return $url;
} | [
"public",
"static",
"function",
"tumblr",
"(",
"Url",
"$",
"url",
")",
"{",
"if",
"(",
"(",
"$",
"value",
"=",
"$",
"url",
"->",
"getQueryParameter",
"(",
"'z'",
")",
")",
")",
"{",
"return",
"Url",
"::",
"create",
"(",
"$",
"value",
")",
";",
"}... | Redirect the tumblr url
@param Url $url
@return Url | [
"Redirect",
"the",
"tumblr",
"url"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/Redirects.php#L103-L110 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getConfig | public function getConfig($name, $default = null)
{
$value = $this->config->get($name);
return $value === null ? $default : $value;
} | php | public function getConfig($name, $default = null)
{
$value = $this->config->get($name);
return $value === null ? $default : $value;
} | [
"public",
"function",
"getConfig",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"$",
"name",
")",
";",
"return",
"$",
"value",
"===",
"null",
"?",
"$",
"default",
... | Get a config value.
@param string $name
@param mixed $default
@return string|null | [
"Get",
"a",
"config",
"value",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L142-L147 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getType | public function getType()
{
$code = $this->code;
if (empty($code)) {
return 'link';
}
if (strpos($code, '</video>')) {
return 'video';
}
//Get the most repeated type
$types = [];
foreach ($this->providers as $provider) {
... | php | public function getType()
{
$code = $this->code;
if (empty($code)) {
return 'link';
}
if (strpos($code, '</video>')) {
return 'video';
}
//Get the most repeated type
$types = [];
foreach ($this->providers as $provider) {
... | [
"public",
"function",
"getType",
"(",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"code",
";",
"if",
"(",
"empty",
"(",
"$",
"code",
")",
")",
"{",
"return",
"'link'",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"code",
",",
"'</video>'",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L184-L215 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getCode | public function getCode()
{
//Width and height deppends to the code
$this->width = null;
$this->height = null;
$codes = [];
foreach ($this->providers as $provider) {
$code = $provider->getCode();
if (!empty($code)) {
$codes[] = [
... | php | public function getCode()
{
//Width and height deppends to the code
$this->width = null;
$this->height = null;
$codes = [];
foreach ($this->providers as $provider) {
$code = $provider->getCode();
if (!empty($code)) {
$codes[] = [
... | [
"public",
"function",
"getCode",
"(",
")",
"{",
"//Width and height deppends to the code",
"$",
"this",
"->",
"width",
"=",
"null",
";",
"$",
"this",
"->",
"height",
"=",
"null",
";",
"$",
"codes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L240-L280 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getHtml | public function getHtml()
{
$code = $this->code;
if (empty($code)) {
return;
}
$errors = libxml_use_internal_errors(true);
$entities = libxml_disable_entity_loader(true);
$dom = new \DOMDocument();
$dom->loadHTML($code);
libxml_use_inte... | php | public function getHtml()
{
$code = $this->code;
if (empty($code)) {
return;
}
$errors = libxml_use_internal_errors(true);
$entities = libxml_disable_entity_loader(true);
$dom = new \DOMDocument();
$dom->loadHTML($code);
libxml_use_inte... | [
"public",
"function",
"getHtml",
"(",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"code",
";",
"if",
"(",
"empty",
"(",
"$",
"code",
")",
")",
"{",
"return",
";",
"}",
"$",
"errors",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",... | Returns the code as DOMNodeList elements
@return \DOMNodeList|null | [
"Returns",
"the",
"code",
"as",
"DOMNodeList",
"elements"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L287-L305 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getUrl | public function getUrl()
{
$default = (string) $this->getResponse()->getUrl();
$blacklist = $this->getConfig('url_blacklist');
//some sites returns the homepage as canonical
$homeUrl = $this->getResponse()->getUrl()->getAbsolute('/');
return $this->getFirstFromProviders(fun... | php | public function getUrl()
{
$default = (string) $this->getResponse()->getUrl();
$blacklist = $this->getConfig('url_blacklist');
//some sites returns the homepage as canonical
$homeUrl = $this->getResponse()->getUrl()->getAbsolute('/');
return $this->getFirstFromProviders(fun... | [
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"default",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"$",
"blacklist",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'url_blacklist'",
")",
";"... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L310-L331 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getProviderIconsUrls | public function getProviderIconsUrls()
{
$urls = [
$this->getResponse()->getUrl()->getAbsolute('/favicon.ico'),
$this->getResponse()->getUrl()->getAbsolute('/favicon.png'),
];
foreach ($this->providers as $provider) {
foreach ($provider->getProviderIconsU... | php | public function getProviderIconsUrls()
{
$urls = [
$this->getResponse()->getUrl()->getAbsolute('/favicon.ico'),
$this->getResponse()->getUrl()->getAbsolute('/favicon.png'),
];
foreach ($this->providers as $provider) {
foreach ($provider->getProviderIconsU... | [
"public",
"function",
"getProviderIconsUrls",
"(",
")",
"{",
"$",
"urls",
"=",
"[",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
"->",
"getAbsolute",
"(",
"'/favicon.ico'",
")",
",",
"$",
"this",
"->",
"getResponse",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L356-L372 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getProviderIcon | public function getProviderIcon()
{
$icons = $this->providerIcons;
if (empty($icons)) {
return null;
}
$sizes = [];
foreach ($icons as $icon) {
$sizes[$icon['url']] = $icon['size'];
}
return static::getBigger($sizes);
} | php | public function getProviderIcon()
{
$icons = $this->providerIcons;
if (empty($icons)) {
return null;
}
$sizes = [];
foreach ($icons as $icon) {
$sizes[$icon['url']] = $icon['size'];
}
return static::getBigger($sizes);
} | [
"public",
"function",
"getProviderIcon",
"(",
")",
"{",
"$",
"icons",
"=",
"$",
"this",
"->",
"providerIcons",
";",
"if",
"(",
"empty",
"(",
"$",
"icons",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"sizes",
"=",
"[",
"]",
";",
"foreach",
"(",
... | Gets the best icon provider
@return string|null | [
"Gets",
"the",
"best",
"icon",
"provider"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L390-L405 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getProviderName | public function getProviderName()
{
$default = $this->getResponse()->getUrl()->getDomain();
return $this->getFirstFromProviders(function (Provider $provider) {
return $provider->getProviderName();
}, $default);
} | php | public function getProviderName()
{
$default = $this->getResponse()->getUrl()->getDomain();
return $this->getFirstFromProviders(function (Provider $provider) {
return $provider->getProviderName();
}, $default);
} | [
"public",
"function",
"getProviderName",
"(",
")",
"{",
"$",
"default",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
"->",
"getDomain",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getFirstFromProviders",
"(",
"function",
"(... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L410-L417 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getProviderUrl | public function getProviderUrl()
{
$url = $this->getResponse()->getUrl();
$default = $url->getScheme().'://'.$url->getDomain(true);
return $this->getFirstFromProviders(function (Provider $provider) {
return $provider->getProviderUrl();
}, $default);
} | php | public function getProviderUrl()
{
$url = $this->getResponse()->getUrl();
$default = $url->getScheme().'://'.$url->getDomain(true);
return $this->getFirstFromProviders(function (Provider $provider) {
return $provider->getProviderUrl();
}, $default);
} | [
"public",
"function",
"getProviderUrl",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"$",
"default",
"=",
"$",
"url",
"->",
"getScheme",
"(",
")",
".",
"'://'",
".",
"$",
"url",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L422-L430 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getImagesUrls | public function getImagesUrls()
{
$urls = $this->getAllFromProviders(function (Provider $provider) {
return $provider->getImagesUrls();
});
$blacklist = $this->getConfig('images_blacklist');
if (!empty($blacklist)) {
$urls = array_filter($urls, function ($ur... | php | public function getImagesUrls()
{
$urls = $this->getAllFromProviders(function (Provider $provider) {
return $provider->getImagesUrls();
});
$blacklist = $this->getConfig('images_blacklist');
if (!empty($blacklist)) {
$urls = array_filter($urls, function ($ur... | [
"public",
"function",
"getImagesUrls",
"(",
")",
"{",
"$",
"urls",
"=",
"$",
"this",
"->",
"getAllFromProviders",
"(",
"function",
"(",
"Provider",
"$",
"provider",
")",
"{",
"return",
"$",
"provider",
"->",
"getImagesUrls",
"(",
")",
";",
"}",
")",
";",... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L435-L450 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getImage | public function getImage()
{
$this->imageWidth = null;
$this->imageHeight = null;
$images = $this->images;
$bigger = (bool) $this->getConfig('choose_bigger_image');
$minWidth = $this->getConfig('min_image_width', 1);
$minHeight = $this->getConfig('min_image_height', ... | php | public function getImage()
{
$this->imageWidth = null;
$this->imageHeight = null;
$images = $this->images;
$bigger = (bool) $this->getConfig('choose_bigger_image');
$minWidth = $this->getConfig('min_image_width', 1);
$minHeight = $this->getConfig('min_image_height', ... | [
"public",
"function",
"getImage",
"(",
")",
"{",
"$",
"this",
"->",
"imageWidth",
"=",
"null",
";",
"$",
"this",
"->",
"imageHeight",
"=",
"null",
";",
"$",
"images",
"=",
"$",
"this",
"->",
"images",
";",
"$",
"bigger",
"=",
"(",
"bool",
")",
"$",... | Gets the best image
@return string|null | [
"Gets",
"the",
"best",
"image"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L468-L510 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getAspectRatio | public function getAspectRatio()
{
if ($this->width !== null
&& (strpos($this->width, '%') === false)
&& $this->height !== null && (strpos($this->height, '%') === false)) {
return round(($this->height / $this->width) * 100, 3);
}
return null;
} | php | public function getAspectRatio()
{
if ($this->width !== null
&& (strpos($this->width, '%') === false)
&& $this->height !== null && (strpos($this->height, '%') === false)) {
return round(($this->height / $this->width) * 100, 3);
}
return null;
} | [
"public",
"function",
"getAspectRatio",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"width",
"!==",
"null",
"&&",
"(",
"strpos",
"(",
"$",
"this",
"->",
"width",
",",
"'%'",
")",
"===",
"false",
")",
"&&",
"$",
"this",
"->",
"height",
"!==",
"null... | Gets the aspect ratio of the embedded widget
(useful to make it responsive).
@return float|null | [
"Gets",
"the",
"aspect",
"ratio",
"of",
"the",
"embedded",
"widget",
"(",
"useful",
"to",
"make",
"it",
"responsive",
")",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L562-L570 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.dispatchImagesInfo | private function dispatchImagesInfo($urls)
{
if (empty($urls)) {
return [];
}
$requests = [];
foreach ($urls as $url) {
$requests[] = Url::create($url);
}
return array_map(
function (ImageResponse $response) {
ret... | php | private function dispatchImagesInfo($urls)
{
if (empty($urls)) {
return [];
}
$requests = [];
foreach ($urls as $url) {
$requests[] = Url::create($url);
}
return array_map(
function (ImageResponse $response) {
ret... | [
"private",
"function",
"dispatchImagesInfo",
"(",
"$",
"urls",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"urls",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"requests",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"url",
")",
... | Get images info.
@param array $urls
@return array | [
"Get",
"images",
"info",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L609-L633 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getBigger | protected static function getBigger(array $values)
{
$bigger = null;
foreach ($values as $value => $repeat) {
if ($bigger === null || $repeat > $values[$bigger]) {
$bigger = $value;
}
}
return $bigger;
} | php | protected static function getBigger(array $values)
{
$bigger = null;
foreach ($values as $value => $repeat) {
if ($bigger === null || $repeat > $values[$bigger]) {
$bigger = $value;
}
}
return $bigger;
} | [
"protected",
"static",
"function",
"getBigger",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"bigger",
"=",
"null",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
"=>",
"$",
"repeat",
")",
"{",
"if",
"(",
"$",
"bigger",
"===",
"null",
"||",
... | Returns the key of the bigger value in an array
@param array $values
@return string|null | [
"Returns",
"the",
"key",
"of",
"the",
"bigger",
"value",
"in",
"an",
"array"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L642-L653 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getFirstFromProviders | protected function getFirstFromProviders(callable $callable, $default = null)
{
$values = array_filter(array_map($callable, $this->providers));
return empty($values) ? $default : current($values);
} | php | protected function getFirstFromProviders(callable $callable, $default = null)
{
$values = array_filter(array_map($callable, $this->providers));
return empty($values) ? $default : current($values);
} | [
"protected",
"function",
"getFirstFromProviders",
"(",
"callable",
"$",
"callable",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"array_filter",
"(",
"array_map",
"(",
"$",
"callable",
",",
"$",
"this",
"->",
"providers",
")",
")",
";",
... | Returns the first value of the providers
@param callable $callable
@param string|null $default
@return string|null | [
"Returns",
"the",
"first",
"value",
"of",
"the",
"providers"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L663-L668 |
oscarotero/Embed | src/Adapters/Adapter.php | Adapter.getAllFromProviders | protected function getAllFromProviders(callable $callable)
{
$values = array_filter(array_map($callable, $this->providers));
$all = [];
foreach ($values as $value) {
foreach ($value as $v) {
if (!in_array($v, $all, true)) {
$all[] = $v;
... | php | protected function getAllFromProviders(callable $callable)
{
$values = array_filter(array_map($callable, $this->providers));
$all = [];
foreach ($values as $value) {
foreach ($value as $v) {
if (!in_array($v, $all, true)) {
$all[] = $v;
... | [
"protected",
"function",
"getAllFromProviders",
"(",
"callable",
"$",
"callable",
")",
"{",
"$",
"values",
"=",
"array_filter",
"(",
"array_map",
"(",
"$",
"callable",
",",
"$",
"this",
"->",
"providers",
")",
")",
";",
"$",
"all",
"=",
"[",
"]",
";",
... | Returns the all values from the providers
@param callable $callable
@return array | [
"Returns",
"the",
"all",
"values",
"from",
"the",
"providers"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Adapter.php#L677-L691 |
oscarotero/Embed | src/Http/CurlDispatcher.php | CurlDispatcher.dispatch | public function dispatch(Url $url)
{
$options = $this->config;
$extension = $url->getExtension();
if (!empty($extension) && isset(self::$acceptHeaders[$extension])) {
$options[CURLOPT_HTTPHEADER] = ['Accept: '.self::$acceptHeaders[$extension]];
} else {
$opt... | php | public function dispatch(Url $url)
{
$options = $this->config;
$extension = $url->getExtension();
if (!empty($extension) && isset(self::$acceptHeaders[$extension])) {
$options[CURLOPT_HTTPHEADER] = ['Accept: '.self::$acceptHeaders[$extension]];
} else {
$opt... | [
"public",
"function",
"dispatch",
"(",
"Url",
"$",
"url",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"config",
";",
"$",
"extension",
"=",
"$",
"url",
"->",
"getExtension",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"extension",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/CurlDispatcher.php#L90-L125 |
oscarotero/Embed | src/Http/CurlDispatcher.php | CurlDispatcher.exec | protected function exec(Url $url, array $options)
{
$connection = curl_init((string) $url);
curl_setopt_array($connection, $options);
$curl = new CurlResult($connection);
//Get only text responses
$curl->onHeader(function ($name, $value, $data) {
if ($name === '... | php | protected function exec(Url $url, array $options)
{
$connection = curl_init((string) $url);
curl_setopt_array($connection, $options);
$curl = new CurlResult($connection);
//Get only text responses
$curl->onHeader(function ($name, $value, $data) {
if ($name === '... | [
"protected",
"function",
"exec",
"(",
"Url",
"$",
"url",
",",
"array",
"$",
"options",
")",
"{",
"$",
"connection",
"=",
"curl_init",
"(",
"(",
"string",
")",
"$",
"url",
")",
";",
"curl_setopt_array",
"(",
"$",
"connection",
",",
"$",
"options",
")",
... | Execute a curl request
@param Url $url
@param array $options
@return Response | [
"Execute",
"a",
"curl",
"request"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/CurlDispatcher.php#L135-L168 |
oscarotero/Embed | src/Http/CurlDispatcher.php | CurlDispatcher.dispatchImages | public function dispatchImages(array $urls)
{
if (empty($urls)) {
return [];
}
$curl_multi = curl_multi_init();
$responses = [];
$connections = [];
foreach ($urls as $k => $url) {
if ($url->getScheme() === 'data') {
$response ... | php | public function dispatchImages(array $urls)
{
if (empty($urls)) {
return [];
}
$curl_multi = curl_multi_init();
$responses = [];
$connections = [];
foreach ($urls as $k => $url) {
if ($url->getScheme() === 'data') {
$response ... | [
"public",
"function",
"dispatchImages",
"(",
"array",
"$",
"urls",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"urls",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"curl_multi",
"=",
"curl_multi_init",
"(",
")",
";",
"$",
"responses",
"=",
"[",
"]... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/CurlDispatcher.php#L174-L258 |
oscarotero/Embed | src/Providers/OEmbed/Embedly.php | Embedly.create | public static function create(Adapter $adapter)
{
$key = $adapter->getConfig('oembed[embedly_key]');
if (!empty($key)) {
return new static($adapter->getResponse(), $key);
}
} | php | public static function create(Adapter $adapter)
{
$key = $adapter->getConfig('oembed[embedly_key]');
if (!empty($key)) {
return new static($adapter->getResponse(), $key);
}
} | [
"public",
"static",
"function",
"create",
"(",
"Adapter",
"$",
"adapter",
")",
"{",
"$",
"key",
"=",
"$",
"adapter",
"->",
"getConfig",
"(",
"'oembed[embedly_key]'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"new",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OEmbed/Embedly.php#L17-L24 |
oscarotero/Embed | src/Providers/OEmbed/Embedly.php | Embedly.getEndPoint | public function getEndPoint()
{
return Url::create('http://api.embed.ly/1/oembed')
->withQueryParameters([
'url' => (string) $this->response->getUrl(),
'format' => 'json',
'key' => $this->key,
]);
} | php | public function getEndPoint()
{
return Url::create('http://api.embed.ly/1/oembed')
->withQueryParameters([
'url' => (string) $this->response->getUrl(),
'format' => 'json',
'key' => $this->key,
]);
} | [
"public",
"function",
"getEndPoint",
"(",
")",
"{",
"return",
"Url",
"::",
"create",
"(",
"'http://api.embed.ly/1/oembed'",
")",
"->",
"withQueryParameters",
"(",
"[",
"'url'",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"response",
"->",
"getUrl",
"(",
")"... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/OEmbed/Embedly.php#L41-L49 |
oscarotero/Embed | src/Embed.php | Embed.create | public static function create($url, array $config = null, DispatcherInterface $dispatcher = null)
{
if (!($url instanceof Url)) {
$url = Url::create($url);
}
if ($config === null) {
$config = self::$default_config;
} else {
$config += self::$defau... | php | public static function create($url, array $config = null, DispatcherInterface $dispatcher = null)
{
if (!($url instanceof Url)) {
$url = Url::create($url);
}
if ($config === null) {
$config = self::$default_config;
} else {
$config += self::$defau... | [
"public",
"static",
"function",
"create",
"(",
"$",
"url",
",",
"array",
"$",
"config",
"=",
"null",
",",
"DispatcherInterface",
"$",
"dispatcher",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"url",
"instanceof",
"Url",
")",
")",
"{",
"$",
"url"... | Gets the info from an url.
@param Url|string $url
@param array|null $config
@param DispatcherInterface|null $dispatcher
@return Adapter | [
"Gets",
"the",
"info",
"from",
"an",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Embed.php#L65-L103 |
oscarotero/Embed | src/Embed.php | Embed.process | private static function process(Url $url, array $config, DispatcherInterface $dispatcher)
{
$response = $dispatcher->dispatch($url);
//If is a file use File Adapter
$adapter = self::getClass('File', $config);
if ($adapter::check($response)) {
return new $adapter($respon... | php | private static function process(Url $url, array $config, DispatcherInterface $dispatcher)
{
$response = $dispatcher->dispatch($url);
//If is a file use File Adapter
$adapter = self::getClass('File', $config);
if ($adapter::check($response)) {
return new $adapter($respon... | [
"private",
"static",
"function",
"process",
"(",
"Url",
"$",
"url",
",",
"array",
"$",
"config",
",",
"DispatcherInterface",
"$",
"dispatcher",
")",
"{",
"$",
"response",
"=",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"$",
"url",
")",
";",
"//If is a file ... | Process the url.
@param Url $url
@param array $config
@param DispatcherInterface $dispatcher
@throws Exceptions\InvalidUrlException If the urls is not valid
@return Adapter | [
"Process",
"the",
"url",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Embed.php#L116-L150 |
oscarotero/Embed | src/Embed.php | Embed.getClass | private static function getClass($name, array $config)
{
if (!empty($config['custom_adapters_namespace'])) {
$namespaces = (array) $config['custom_adapters_namespace'];
foreach ($namespaces as $namespace) {
$class = $namespace.$name;
if (class_exists... | php | private static function getClass($name, array $config)
{
if (!empty($config['custom_adapters_namespace'])) {
$namespaces = (array) $config['custom_adapters_namespace'];
foreach ($namespaces as $namespace) {
$class = $namespace.$name;
if (class_exists... | [
"private",
"static",
"function",
"getClass",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'custom_adapters_namespace'",
"]",
")",
")",
"{",
"$",
"namespaces",
"=",
"(",
"array",
")",
"$",
... | Returns a class name using the custom_adapters_namespace
@param string $name
@param array $config
@return string | [
"Returns",
"a",
"class",
"name",
"using",
"the",
"custom_adapters_namespace"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Embed.php#L160-L175 |
oscarotero/Embed | src/Adapters/Carto.php | Carto.getCode | public function getCode()
{
$this->width = null;
$this->height = 520;
$url = $this->getResponse()->getUrl()->withDirectoryPosition(2, 'embed_map');
return Utils::iframe($url, '100%', $this->height);
} | php | public function getCode()
{
$this->width = null;
$this->height = 520;
$url = $this->getResponse()->getUrl()->withDirectoryPosition(2, 'embed_map');
return Utils::iframe($url, '100%', $this->height);
} | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"this",
"->",
"width",
"=",
"null",
";",
"$",
"this",
"->",
"height",
"=",
"520",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getUrl",
"(",
")",
"->",
"withDirectoryP... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Carto.php#L26-L34 |
oscarotero/Embed | src/Adapters/Archive.php | Archive.init | protected function init()
{
parent::init();
$this->providers = ['archive' => new Api\Archive($this)] + $this->providers;
} | php | protected function init()
{
parent::init();
$this->providers = ['archive' => new Api\Archive($this)] + $this->providers;
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"providers",
"=",
"[",
"'archive'",
"=>",
"new",
"Api",
"\\",
"Archive",
"(",
"$",
"this",
")",
"]",
"+",
"$",
"this",
"->",
"providers",
";",... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Archive.php#L27-L32 |
oscarotero/Embed | src/Adapters/Archive.php | Archive.getCode | public function getCode()
{
return Utils::iframe(str_replace('/details/', '/embed/', $this->url), $this->width, $this->height);
} | php | public function getCode()
{
return Utils::iframe(str_replace('/details/', '/embed/', $this->url), $this->width, $this->height);
} | [
"public",
"function",
"getCode",
"(",
")",
"{",
"return",
"Utils",
"::",
"iframe",
"(",
"str_replace",
"(",
"'/details/'",
",",
"'/embed/'",
",",
"$",
"this",
"->",
"url",
")",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Archive.php#L37-L40 |
oscarotero/Embed | src/Providers/Html.php | Html.getTags | public function getTags()
{
$keywords = $this->bag->get('keywords').','.$this->bag->get('news_keywords');
return array_filter(
array_map('trim', explode(',', $keywords)),
function ($value) {
return !empty($value) && substr($value, -3) !== '...';
}... | php | public function getTags()
{
$keywords = $this->bag->get('keywords').','.$this->bag->get('news_keywords');
return array_filter(
array_map('trim', explode(',', $keywords)),
function ($value) {
return !empty($value) && substr($value, -3) !== '...';
}... | [
"public",
"function",
"getTags",
"(",
")",
"{",
"$",
"keywords",
"=",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'keywords'",
")",
".",
"','",
".",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'news_keywords'",
")",
";",
"return",
"array_filter",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L66-L76 |
oscarotero/Embed | src/Providers/Html.php | Html.getCode | public function getCode()
{
$src = $this->normalizeUrl($this->bag->get('video_src'));
if ($src !== null) {
switch ($this->bag->get('video_type')) {
case 'application/x-shockwave-flash':
return Utils::flash($src, $this->getWidth(), $this->getHeight());... | php | public function getCode()
{
$src = $this->normalizeUrl($this->bag->get('video_src'));
if ($src !== null) {
switch ($this->bag->get('video_type')) {
case 'application/x-shockwave-flash':
return Utils::flash($src, $this->getWidth(), $this->getHeight());... | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"src",
"=",
"$",
"this",
"->",
"normalizeUrl",
"(",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'video_src'",
")",
")",
";",
"if",
"(",
"$",
"src",
"!==",
"null",
")",
"{",
"switch",
"(",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L89-L99 |
oscarotero/Embed | src/Providers/Html.php | Html.getAuthorName | public function getAuthorName()
{
return $this->bag->get('author') ?: $this->bag->get('article:author') ?: $this->bag->get('contributors');
} | php | public function getAuthorName()
{
return $this->bag->get('author') ?: $this->bag->get('article:author') ?: $this->bag->get('contributors');
} | [
"public",
"function",
"getAuthorName",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'author'",
")",
"?",
":",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'article:author'",
")",
"?",
":",
"$",
"this",
"->",
"bag",
"->",
"g... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L112-L115 |
oscarotero/Embed | src/Providers/Html.php | Html.getImagesUrls | public function getImagesUrls()
{
$images = $this->normalizeUrls($this->bag->get('images'));
if (!empty($images)) {
$maxImages = $this->adapter->getConfig('html[max_images]', -1);
if ($maxImages > -1) {
return array_slice($images, 0, $maxImages);
... | php | public function getImagesUrls()
{
$images = $this->normalizeUrls($this->bag->get('images'));
if (!empty($images)) {
$maxImages = $this->adapter->getConfig('html[max_images]', -1);
if ($maxImages > -1) {
return array_slice($images, 0, $maxImages);
... | [
"public",
"function",
"getImagesUrls",
"(",
")",
"{",
"$",
"images",
"=",
"$",
"this",
"->",
"normalizeUrls",
"(",
"$",
"this",
"->",
"bag",
"->",
"get",
"(",
"'images'",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"images",
")",
")",
"{",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L128-L141 |
oscarotero/Embed | src/Providers/Html.php | Html.getPublishedTime | public function getPublishedTime()
{
$keys = [
'article:published_time',
'created',
'date',
'datepublished',
'datePublished',
'newsrepublic:publish_date',
'pagerender',
'pub_date',
'publication-date',... | php | public function getPublishedTime()
{
$keys = [
'article:published_time',
'created',
'date',
'datepublished',
'datePublished',
'newsrepublic:publish_date',
'pagerender',
'pub_date',
'publication-date',... | [
"public",
"function",
"getPublishedTime",
"(",
")",
"{",
"$",
"keys",
"=",
"[",
"'article:published_time'",
",",
"'created'",
",",
"'date'",
",",
"'datepublished'",
",",
"'datePublished'",
",",
"'newsrepublic:publish_date'",
",",
"'pagerender'",
",",
"'pub_date'",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L162-L187 |
oscarotero/Embed | src/Providers/Html.php | Html.getLinkedData | public function getLinkedData()
{
$data = [];
if (!($html = $this->adapter->getResponse()->getHtmlContent())) {
return $data;
}
foreach ($html->getElementsByTagName('script') as $script) {
if ($script->hasAttribute('type') && strtolower($script->getAttribute... | php | public function getLinkedData()
{
$data = [];
if (!($html = $this->adapter->getResponse()->getHtmlContent())) {
return $data;
}
foreach ($html->getElementsByTagName('script') as $script) {
if ($script->hasAttribute('type') && strtolower($script->getAttribute... | [
"public",
"function",
"getLinkedData",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"(",
"$",
"html",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getResponse",
"(",
")",
"->",
"getHtmlContent",
"(",
")",
")",
")",
"{",
"return",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L200-L225 |
oscarotero/Embed | src/Providers/Html.php | Html.extractLinks | private function extractLinks(DOMDocument $html)
{
foreach ($html->getElementsByTagName('link') as $link) {
if ($link->hasAttribute('rel') && $link->hasAttribute('href')) {
$rel = trim(strtolower($link->getAttribute('rel')));
$href = $link->getAttribute('href');
... | php | private function extractLinks(DOMDocument $html)
{
foreach ($html->getElementsByTagName('link') as $link) {
if ($link->hasAttribute('rel') && $link->hasAttribute('href')) {
$rel = trim(strtolower($link->getAttribute('rel')));
$href = $link->getAttribute('href');
... | [
"private",
"function",
"extractLinks",
"(",
"DOMDocument",
"$",
"html",
")",
"{",
"foreach",
"(",
"$",
"html",
"->",
"getElementsByTagName",
"(",
"'link'",
")",
"as",
"$",
"link",
")",
"{",
"if",
"(",
"$",
"link",
"->",
"hasAttribute",
"(",
"'rel'",
")",... | Extract information from the <link> elements.
@param DOMDocument $html | [
"Extract",
"information",
"from",
"the",
"<link",
">",
"elements",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L232-L275 |
oscarotero/Embed | src/Providers/Html.php | Html.extractMetas | private function extractMetas(DOMDocument $html)
{
foreach ($html->getElementsByTagName('meta') as $meta) {
$value = $meta->getAttribute('content');
if (empty($value)) {
continue;
}
if ($meta->hasAttribute('name')) {
$name = t... | php | private function extractMetas(DOMDocument $html)
{
foreach ($html->getElementsByTagName('meta') as $meta) {
$value = $meta->getAttribute('content');
if (empty($value)) {
continue;
}
if ($meta->hasAttribute('name')) {
$name = t... | [
"private",
"function",
"extractMetas",
"(",
"DOMDocument",
"$",
"html",
")",
"{",
"foreach",
"(",
"$",
"html",
"->",
"getElementsByTagName",
"(",
"'meta'",
")",
"as",
"$",
"meta",
")",
"{",
"$",
"value",
"=",
"$",
"meta",
"->",
"getAttribute",
"(",
"'con... | Extract information from the <meta> elements.
@param DOMDocument $html | [
"Extract",
"information",
"from",
"the",
"<meta",
">",
"elements",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L282-L317 |
oscarotero/Embed | src/Providers/Html.php | Html.extractImages | private function extractImages(DOMDocument $html)
{
if ($this->adapter->getConfig('html[max_images]') === 0) {
return;
}
//Extract only from the main element
$main = self::getMainElement($html);
if (!$main) {
return;
}
$url = $this->... | php | private function extractImages(DOMDocument $html)
{
if ($this->adapter->getConfig('html[max_images]') === 0) {
return;
}
//Extract only from the main element
$main = self::getMainElement($html);
if (!$main) {
return;
}
$url = $this->... | [
"private",
"function",
"extractImages",
"(",
"DOMDocument",
"$",
"html",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"adapter",
"->",
"getConfig",
"(",
"'html[max_images]'",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"//Extract only from the main element",
"$"... | Extract <img> elements.
@param DOMDocument $html | [
"Extract",
"<img",
">",
"elements",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L324-L387 |
oscarotero/Embed | src/Providers/Html.php | Html.imageIsValid | private static function imageIsValid(Url $url, Url $baseUrl, $externalImages)
{
//base64 or same domain
if ($url->getContent() !== null || $url->getDomain() === $baseUrl->getDomain()) {
return true;
}
return is_bool($externalImages) ? $externalImages : $url->match($exter... | php | private static function imageIsValid(Url $url, Url $baseUrl, $externalImages)
{
//base64 or same domain
if ($url->getContent() !== null || $url->getDomain() === $baseUrl->getDomain()) {
return true;
}
return is_bool($externalImages) ? $externalImages : $url->match($exter... | [
"private",
"static",
"function",
"imageIsValid",
"(",
"Url",
"$",
"url",
",",
"Url",
"$",
"baseUrl",
",",
"$",
"externalImages",
")",
"{",
"//base64 or same domain",
"if",
"(",
"$",
"url",
"->",
"getContent",
"(",
")",
"!==",
"null",
"||",
"$",
"url",
"-... | Check whether a image url is valid or not.
@param Url $url
@param Url $baseUrl
@param mixed $externalImages
@return bool | [
"Check",
"whether",
"a",
"image",
"url",
"is",
"valid",
"or",
"not",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Providers/Html.php#L398-L406 |
oscarotero/Embed | src/Http/AbstractResponse.php | AbstractResponse.isValid | public function isValid(array $codes = null)
{
if ($codes === null) {
return $this->statusCode === 200;
}
return in_array($this->statusCode, $codes);
} | php | public function isValid(array $codes = null)
{
if ($codes === null) {
return $this->statusCode === 200;
}
return in_array($this->statusCode, $codes);
} | [
"public",
"function",
"isValid",
"(",
"array",
"$",
"codes",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"codes",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"statusCode",
"===",
"200",
";",
"}",
"return",
"in_array",
"(",
"$",
"this",
"->",
"... | Check if the response is valid or not.
@param array $codes
@return bool | [
"Check",
"if",
"the",
"response",
"is",
"valid",
"or",
"not",
"."
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Http/AbstractResponse.php#L118-L125 |
oscarotero/Embed | src/Adapters/Jsfiddle.php | Jsfiddle.getCode | public function getCode()
{
$this->width = null;
$this->height = null;
$url = $this->url;
$embed_url = $url.((substr($url, -1) === '/') ? 'embedded/' : '/embedded/');
return Utils::iframe($embed_url);
} | php | public function getCode()
{
$this->width = null;
$this->height = null;
$url = $this->url;
$embed_url = $url.((substr($url, -1) === '/') ? 'embedded/' : '/embedded/');
return Utils::iframe($embed_url);
} | [
"public",
"function",
"getCode",
"(",
")",
"{",
"$",
"this",
"->",
"width",
"=",
"null",
";",
"$",
"this",
"->",
"height",
"=",
"null",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
";",
"$",
"embed_url",
"=",
"$",
"url",
".",
"(",
"(",
"subs... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Jsfiddle.php#L15-L24 |
oscarotero/Embed | src/Adapters/Imageshack.php | Imageshack.init | protected function init()
{
parent::init();
$this->providers = ['imageshack' => new Api\Imageshack($this)] + $this->providers;
} | php | protected function init()
{
parent::init();
$this->providers = ['imageshack' => new Api\Imageshack($this)] + $this->providers;
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"providers",
"=",
"[",
"'imageshack'",
"=>",
"new",
"Api",
"\\",
"Imageshack",
"(",
"$",
"this",
")",
"]",
"+",
"$",
"this",
"->",
"providers",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/oscarotero/Embed/blob/bc80c5da565ae1576aa4bd909949ca15e92badfb/src/Adapters/Imageshack.php#L26-L31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.