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 |
|---|---|---|---|---|---|---|---|---|---|---|
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.getUrl | protected function getUrl($url)
{
try {
$response = $this->webClient->get($url);
} catch (\Exception $e) {
if ($e instanceof ClientException && $e->hasResponse())
throw new YoutubeException($e->getResponse()->getReasonPhrase(), 3);
else
throw new YoutubeException($e->getMessage(), 3);
}
return $response;
} | php | protected function getUrl($url)
{
try {
$response = $this->webClient->get($url);
} catch (\Exception $e) {
if ($e instanceof ClientException && $e->hasResponse())
throw new YoutubeException($e->getResponse()->getReasonPhrase(), 3);
else
throw new YoutubeException($e->getMessage(), 3);
}
return $response;
} | [
"protected",
"function",
"getUrl",
"(",
"$",
"url",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"webClient",
"->",
"get",
"(",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e... | Fetches content of passed URL
@throws YoutubeException If any error happens
@param string $url Address of page to fetch
@return ResponseInterface content of page | [
"Fetches",
"content",
"of",
"passed",
"URL"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L335-L346 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.getVideoInfo | public function getVideoInfo($detailed=false)
{
$result = array();
try {
$response = $this->getUrl('https://www.youtube.com/get_video_info?' . http_build_query(array(
'video_id' => $this->videoId,
'eurl' => 'https://youtube.googleapis.com/v/' . $this->videoId
)));
} catch (YoutubeException $e) {
throw $e;
}
if ($response->getStatusCode() != 200)
throw new YoutubeException('Couldn\'t get video details.', 1);
$data = $this->decodeString($response->getBody());
$failed = (isset($data['status']) && $data['status'] == 'fail');
$usingCipheredSignature = false;
if ($failed) {
if (isset($data['errorcode']) && $data['errorcode'] == '150')
$usingCipheredSignature = true;
else
throw new YoutubeException($data['reason'], $data['errorcode']);
} elseif (
(isset($data['use_cipher_signature']) && $data['use_cipher_signature'] == 'True') ||
(isset($data['probe_url']) && stripos($data['probe_url'], '&signature=') !== false) ||
(isset($data['fflags']) && stripos($data['fflags'], 'html5_progressive_signature_reload=true') !== false) ||
(isset($data['token']) && $data['token'] == '1')
) {
$usingCipheredSignature = true;
$failed = true;
}
if ($failed) {
if ($usingCipheredSignature) {
try {
$response = $this->getUrl(
'https://www.youtube.com/watch?v=' . $this->videoId .
'&gl=US&hl=en&has_verified=1&bpctr=9999999999'
);
} catch (YoutubeException $e) {
throw $e;
}
$response = $response->getBody();
$ytconfig = '';
if (preg_match('/var bootstrap_data = "\)\]\}\'(\{.*?\})";/i', $response, $matches)) {
$ytconfig = json_decode(stripslashes($matches[1]), true);
$ytconfig = $ytconfig['content']['swfcfg'];
} elseif (preg_match('/ytplayer.config\s*=\s*([^\n]+});ytplayer/i', $response, $matches)) {
$ytconfig = json_decode($matches[1], true);
} elseif (preg_match('/class="message">([^<]+)</i', $response, $matches)) {
throw new YoutubeException(trim($matches[1]), 10);
}
$jsAsset = null;
if (preg_match('/<script\s*src="([^"]+)"\s*(type="text\/javascript")?\s*name="player\/base"\s*><\/script>/i', $response, $matches)) {
$jsAsset = $matches[1];
}
if (is_array($ytconfig)) {
$data = array_merge($data, $ytconfig['args']);
if (isset($ytconfig['assets']['js']))
$jsAsset = $ytconfig['assets']['js'];
}
if ($detailed && $jsAsset !== null) {
if (stripos($jsAsset, 'https://') !== 0) {
if (strlen($jsAsset) > 1 && substr($jsAsset, 0, 2) == '//')
$jsAsset = 'https:' . $jsAsset;
else
$jsAsset = 'https://s.ytimg.com' . $jsAsset;
}
try {
$response = $this->getUrl($jsAsset);
} catch (YoutubeException $e) {
throw $e;
}
$code = $response->getBody();
try {
$decoder = new JsDecoder($jsAsset);
if (!$decoder->isInitialized())
$decoder->parseJsCode($code);
$data['decryptionObject'] = $decoder;
} catch (YoutubeException $e) {
// Throwing this exception may not bee a good idea
// the video still might be downloaded without decryption
}
}
} else
throw new YoutubeException($data['reason'], $data['errorcode']);
}
$player = isset($data['player_response']) ? json_decode($data['player_response'], true) : array();
if (isset($player['videoDetails'])) {
$player = $player['videoDetails'];
$data['video_id'] = @$data['video_id'] ?: $player['videoId'];
$data['title'] = @$data['title'] ?: $player['title'];
$data['length_seconds'] = @$data['length_seconds'] ?: $player['lengthSeconds'];
$data['view_count'] = @$data['view_count'] ?: $player['viewCount'];
$data['author'] = @$data['author'] ?: $player['author'];
$data['live_playback'] = @$data['live_playback'] ?: $player['isLiveContent'];
// TODO: Do something about caption
// if (!@$data['caption_tracks'] && isset($player['captions']['playerCaptionsTracklistRenderer']['captionTracks'])) {
// $data['caption_tracks'] = array_map(function($track='')
// {
// # code...
// }, $player['captions']['playerCaptionsTracklistRenderer']['captionTracks']);
// }
}
$result['title'] = trim(@$data['title'] ?: '');
$result['image'] = array(
'max_resolution' => 'https://i.ytimg.com/vi/' . $this->videoId . '/maxresdefault.jpg',
'high_quality' => 'https://i.ytimg.com/vi/' . $this->videoId . '/hqdefault.jpg',
'medium_quality' => 'https://i.ytimg.com/vi/' . $this->videoId . '/mqdefault.jpg',
'standard' => 'https://i.ytimg.com/vi/' . $this->videoId . '/sddefault.jpg',
'thumbnails' => array(
'https://i.ytimg.com/vi/' . $this->videoId . '/default.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/0.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/1.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/2.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/3.jpg'
)
);
$result['length_seconds'] = @$data['length_seconds'] ?: 0;
$result['duration'] = vsprintf('%02d:%02d:%02d', $this->parseFloatTime(@$result['length_seconds'] ?: 0));
$result['video_id'] = @$data['video_id'] ?: '';
$result['views'] = @$data['view_count'] ?: 0;
$result['rating'] = round(@$data['avg_rating'] ?: 0);
$result['author'] = trim(@$data['author'] ?: '');
$result['captions'] = array();
if (isset($data['has_cc']) && $data['has_cc'] === 'True')
$result['captions'] = $this->getCaptions($data, $detailed);
$sanitizer = &$this->sanitizeFileName;
$filename = $sanitizer($result['title']);
$isLive = false;
if (isset($data['ps']) && $data['ps'] == 'live') $isLive = true;
if (isset($data['hlsdvr']) && $data['hlsdvr'] == '1') $isLive = true;
if (isset($data['live_playback']) && $data['live_playback'] == '1') $isLive = true;
if ($isLive)
{
if (!isset($data['hlsvp']))
throw new YoutubeException('This live event is over.', 2);
$result['stream_url'] = $data['hlsvp'];
}
else
{
$stream_maps = array();
if (isset($data['url_encoded_fmt_stream_map']))
$stream_maps = explode(',', $data['url_encoded_fmt_stream_map']);
foreach ($stream_maps as $key => $value) {
$stream_maps[$key] = $this->decodeString($value);
if (isset($data['decryptionObject']) && isset($stream_maps[$key]['s'])) {
try {
$stream_maps[$key]['url'] .= '&signature=' . $this->decryptSignature(
$stream_maps[$key]['s'], // Encrypted signature,
$data['decryptionObject'] // Decryption object
);
// TODO: $stream_maps[$key]['url'] .= '&title=' . urlencode($fileName)
} catch (YoutubeException $e) {
throw $e;
}
unset($stream_maps[$key]['s']);
} elseif (isset($stream_maps[$key]['sig'])) {
$stream_maps[$key]['url'] .= '&signature=' . $stream_maps[$key]['sig'];
unset($stream_maps[$key]['sig']);
}
$typeParts = explode(';', $stream_maps[$key]['type']);
// TODO: Use container of known itags as extension here
$stream_maps[$key]['filename'] = $filename . '.' . $this->getExtension(trim($typeParts[0]));
$stream_maps[$key] = (object) $stream_maps[$key];
}
$result['full_formats'] = $stream_maps;
$adaptive_fmts = array();
if (isset($data['adaptive_fmts']))
$adaptive_fmts = explode(',', $data['adaptive_fmts']);
foreach ($adaptive_fmts as $key => $value) {
$adaptive_fmts[$key] = $this->decodeString($value);
if (isset($data['decryptionObject']) && isset($adaptive_fmts[$key]['s'])) {
try {
$adaptive_fmts[$key]['url'] .= '&signature=' . $this->decryptSignature(
$adaptive_fmts[$key]['s'], // Encrypted signature,
$data['decryptionObject'] // Decryption object
);
// TODO: $adaptive_fmts[$key]['url'] .= '&title=' . urlencode($fileName)
} catch (YoutubeException $e) {
throw $e;
}
unset($adaptive_fmts[$key]['s']);
}
$typeParts = explode(';', $adaptive_fmts[$key]['type']);
// TODO: Use container of known itags as extension here
$adaptive_fmts[$key]['filename'] = $filename . '.' . $this->getExtension(trim($typeParts[0]));
$adaptive_fmts[$key] = (object) $adaptive_fmts[$key];
}
$result['adaptive_formats'] = $adaptive_fmts;
}
if (isset($data['decryptionObject']))
unset($data['decryptionObject']);
$result['video_url'] = 'https://www.youtube.com/watch?v=' . $this->videoId;
$lastResult = (object) $result;
$this->videoInfo = $lastResult;
$lastResult->response_type = 'video';
return $lastResult;
} | php | public function getVideoInfo($detailed=false)
{
$result = array();
try {
$response = $this->getUrl('https://www.youtube.com/get_video_info?' . http_build_query(array(
'video_id' => $this->videoId,
'eurl' => 'https://youtube.googleapis.com/v/' . $this->videoId
)));
} catch (YoutubeException $e) {
throw $e;
}
if ($response->getStatusCode() != 200)
throw new YoutubeException('Couldn\'t get video details.', 1);
$data = $this->decodeString($response->getBody());
$failed = (isset($data['status']) && $data['status'] == 'fail');
$usingCipheredSignature = false;
if ($failed) {
if (isset($data['errorcode']) && $data['errorcode'] == '150')
$usingCipheredSignature = true;
else
throw new YoutubeException($data['reason'], $data['errorcode']);
} elseif (
(isset($data['use_cipher_signature']) && $data['use_cipher_signature'] == 'True') ||
(isset($data['probe_url']) && stripos($data['probe_url'], '&signature=') !== false) ||
(isset($data['fflags']) && stripos($data['fflags'], 'html5_progressive_signature_reload=true') !== false) ||
(isset($data['token']) && $data['token'] == '1')
) {
$usingCipheredSignature = true;
$failed = true;
}
if ($failed) {
if ($usingCipheredSignature) {
try {
$response = $this->getUrl(
'https://www.youtube.com/watch?v=' . $this->videoId .
'&gl=US&hl=en&has_verified=1&bpctr=9999999999'
);
} catch (YoutubeException $e) {
throw $e;
}
$response = $response->getBody();
$ytconfig = '';
if (preg_match('/var bootstrap_data = "\)\]\}\'(\{.*?\})";/i', $response, $matches)) {
$ytconfig = json_decode(stripslashes($matches[1]), true);
$ytconfig = $ytconfig['content']['swfcfg'];
} elseif (preg_match('/ytplayer.config\s*=\s*([^\n]+});ytplayer/i', $response, $matches)) {
$ytconfig = json_decode($matches[1], true);
} elseif (preg_match('/class="message">([^<]+)</i', $response, $matches)) {
throw new YoutubeException(trim($matches[1]), 10);
}
$jsAsset = null;
if (preg_match('/<script\s*src="([^"]+)"\s*(type="text\/javascript")?\s*name="player\/base"\s*><\/script>/i', $response, $matches)) {
$jsAsset = $matches[1];
}
if (is_array($ytconfig)) {
$data = array_merge($data, $ytconfig['args']);
if (isset($ytconfig['assets']['js']))
$jsAsset = $ytconfig['assets']['js'];
}
if ($detailed && $jsAsset !== null) {
if (stripos($jsAsset, 'https://') !== 0) {
if (strlen($jsAsset) > 1 && substr($jsAsset, 0, 2) == '//')
$jsAsset = 'https:' . $jsAsset;
else
$jsAsset = 'https://s.ytimg.com' . $jsAsset;
}
try {
$response = $this->getUrl($jsAsset);
} catch (YoutubeException $e) {
throw $e;
}
$code = $response->getBody();
try {
$decoder = new JsDecoder($jsAsset);
if (!$decoder->isInitialized())
$decoder->parseJsCode($code);
$data['decryptionObject'] = $decoder;
} catch (YoutubeException $e) {
// Throwing this exception may not bee a good idea
// the video still might be downloaded without decryption
}
}
} else
throw new YoutubeException($data['reason'], $data['errorcode']);
}
$player = isset($data['player_response']) ? json_decode($data['player_response'], true) : array();
if (isset($player['videoDetails'])) {
$player = $player['videoDetails'];
$data['video_id'] = @$data['video_id'] ?: $player['videoId'];
$data['title'] = @$data['title'] ?: $player['title'];
$data['length_seconds'] = @$data['length_seconds'] ?: $player['lengthSeconds'];
$data['view_count'] = @$data['view_count'] ?: $player['viewCount'];
$data['author'] = @$data['author'] ?: $player['author'];
$data['live_playback'] = @$data['live_playback'] ?: $player['isLiveContent'];
// TODO: Do something about caption
// if (!@$data['caption_tracks'] && isset($player['captions']['playerCaptionsTracklistRenderer']['captionTracks'])) {
// $data['caption_tracks'] = array_map(function($track='')
// {
// # code...
// }, $player['captions']['playerCaptionsTracklistRenderer']['captionTracks']);
// }
}
$result['title'] = trim(@$data['title'] ?: '');
$result['image'] = array(
'max_resolution' => 'https://i.ytimg.com/vi/' . $this->videoId . '/maxresdefault.jpg',
'high_quality' => 'https://i.ytimg.com/vi/' . $this->videoId . '/hqdefault.jpg',
'medium_quality' => 'https://i.ytimg.com/vi/' . $this->videoId . '/mqdefault.jpg',
'standard' => 'https://i.ytimg.com/vi/' . $this->videoId . '/sddefault.jpg',
'thumbnails' => array(
'https://i.ytimg.com/vi/' . $this->videoId . '/default.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/0.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/1.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/2.jpg',
'https://i.ytimg.com/vi/' . $this->videoId . '/3.jpg'
)
);
$result['length_seconds'] = @$data['length_seconds'] ?: 0;
$result['duration'] = vsprintf('%02d:%02d:%02d', $this->parseFloatTime(@$result['length_seconds'] ?: 0));
$result['video_id'] = @$data['video_id'] ?: '';
$result['views'] = @$data['view_count'] ?: 0;
$result['rating'] = round(@$data['avg_rating'] ?: 0);
$result['author'] = trim(@$data['author'] ?: '');
$result['captions'] = array();
if (isset($data['has_cc']) && $data['has_cc'] === 'True')
$result['captions'] = $this->getCaptions($data, $detailed);
$sanitizer = &$this->sanitizeFileName;
$filename = $sanitizer($result['title']);
$isLive = false;
if (isset($data['ps']) && $data['ps'] == 'live') $isLive = true;
if (isset($data['hlsdvr']) && $data['hlsdvr'] == '1') $isLive = true;
if (isset($data['live_playback']) && $data['live_playback'] == '1') $isLive = true;
if ($isLive)
{
if (!isset($data['hlsvp']))
throw new YoutubeException('This live event is over.', 2);
$result['stream_url'] = $data['hlsvp'];
}
else
{
$stream_maps = array();
if (isset($data['url_encoded_fmt_stream_map']))
$stream_maps = explode(',', $data['url_encoded_fmt_stream_map']);
foreach ($stream_maps as $key => $value) {
$stream_maps[$key] = $this->decodeString($value);
if (isset($data['decryptionObject']) && isset($stream_maps[$key]['s'])) {
try {
$stream_maps[$key]['url'] .= '&signature=' . $this->decryptSignature(
$stream_maps[$key]['s'], // Encrypted signature,
$data['decryptionObject'] // Decryption object
);
// TODO: $stream_maps[$key]['url'] .= '&title=' . urlencode($fileName)
} catch (YoutubeException $e) {
throw $e;
}
unset($stream_maps[$key]['s']);
} elseif (isset($stream_maps[$key]['sig'])) {
$stream_maps[$key]['url'] .= '&signature=' . $stream_maps[$key]['sig'];
unset($stream_maps[$key]['sig']);
}
$typeParts = explode(';', $stream_maps[$key]['type']);
// TODO: Use container of known itags as extension here
$stream_maps[$key]['filename'] = $filename . '.' . $this->getExtension(trim($typeParts[0]));
$stream_maps[$key] = (object) $stream_maps[$key];
}
$result['full_formats'] = $stream_maps;
$adaptive_fmts = array();
if (isset($data['adaptive_fmts']))
$adaptive_fmts = explode(',', $data['adaptive_fmts']);
foreach ($adaptive_fmts as $key => $value) {
$adaptive_fmts[$key] = $this->decodeString($value);
if (isset($data['decryptionObject']) && isset($adaptive_fmts[$key]['s'])) {
try {
$adaptive_fmts[$key]['url'] .= '&signature=' . $this->decryptSignature(
$adaptive_fmts[$key]['s'], // Encrypted signature,
$data['decryptionObject'] // Decryption object
);
// TODO: $adaptive_fmts[$key]['url'] .= '&title=' . urlencode($fileName)
} catch (YoutubeException $e) {
throw $e;
}
unset($adaptive_fmts[$key]['s']);
}
$typeParts = explode(';', $adaptive_fmts[$key]['type']);
// TODO: Use container of known itags as extension here
$adaptive_fmts[$key]['filename'] = $filename . '.' . $this->getExtension(trim($typeParts[0]));
$adaptive_fmts[$key] = (object) $adaptive_fmts[$key];
}
$result['adaptive_formats'] = $adaptive_fmts;
}
if (isset($data['decryptionObject']))
unset($data['decryptionObject']);
$result['video_url'] = 'https://www.youtube.com/watch?v=' . $this->videoId;
$lastResult = (object) $result;
$this->videoInfo = $lastResult;
$lastResult->response_type = 'video';
return $lastResult;
} | [
"public",
"function",
"getVideoInfo",
"(",
"$",
"detailed",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"'https://www.youtube.com/get_video_info?'",
".",
"http_build_... | Gets information of Youtube video
@throws YoutubeException If Video ID is wrong or video not exists anymore or it's not viewable anyhow
@param bool $detailed Show more detailed information
@return object Video's title, images, video length, download links, ... | [
"Gets",
"information",
"of",
"Youtube",
"video"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L386-L614 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.getInfo | public function getInfo($getDownloadLinks=false)
{
try {
if ($this->isPlaylist)
return $this->getPlaylistInfo($getDownloadLinks);
return $this->getVideoInfo($getDownloadLinks);
} catch (YoutubeException $e) {
throw $e;
}
} | php | public function getInfo($getDownloadLinks=false)
{
try {
if ($this->isPlaylist)
return $this->getPlaylistInfo($getDownloadLinks);
return $this->getVideoInfo($getDownloadLinks);
} catch (YoutubeException $e) {
throw $e;
}
} | [
"public",
"function",
"getInfo",
"(",
"$",
"getDownloadLinks",
"=",
"false",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"isPlaylist",
")",
"return",
"$",
"this",
"->",
"getPlaylistInfo",
"(",
"$",
"getDownloadLinks",
")",
";",
"return",
"$",
"th... | Gets information of Youtube video or playlist
@throws YoutubeException If Video ID or Playlist Id is wrong or not exists anymore or it's not viewable anyhow
@param bool $getDownloadLinks Also get download links and images for each video
@return object Video's title, images, video length, download links, ... or Playlist's title, author, videos, ... | [
"Gets",
"information",
"of",
"Youtube",
"video",
"or",
"playlist"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L624-L633 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.getCaptions | protected function getCaptions($videoInfo, $detailed=false) {
$index = 0;
$captions = array();
$captionTracks = explode(',', $videoInfo['caption_tracks']);
foreach($captionTracks as $captionTrack) {
$decodedTrack = $this->decodeString($captionTrack);
$language = $index++;
if (isset($decodedTrack['lc']))
$language = $decodedTrack['lc'];
if (isset($decodedTrack['v']) && $decodedTrack['v'][0] != '.')
$language = $decodedTrack['v'];
if ($detailed)
$captions[$language] = $decodedTrack;
else
$captions[$language] = $decodedTrack['n'];
}
return $captions;
} | php | protected function getCaptions($videoInfo, $detailed=false) {
$index = 0;
$captions = array();
$captionTracks = explode(',', $videoInfo['caption_tracks']);
foreach($captionTracks as $captionTrack) {
$decodedTrack = $this->decodeString($captionTrack);
$language = $index++;
if (isset($decodedTrack['lc']))
$language = $decodedTrack['lc'];
if (isset($decodedTrack['v']) && $decodedTrack['v'][0] != '.')
$language = $decodedTrack['v'];
if ($detailed)
$captions[$language] = $decodedTrack;
else
$captions[$language] = $decodedTrack['n'];
}
return $captions;
} | [
"protected",
"function",
"getCaptions",
"(",
"$",
"videoInfo",
",",
"$",
"detailed",
"=",
"false",
")",
"{",
"$",
"index",
"=",
"0",
";",
"$",
"captions",
"=",
"array",
"(",
")",
";",
"$",
"captionTracks",
"=",
"explode",
"(",
"','",
",",
"$",
"video... | Gets caption of Youtube video and returns it as an object
@param array $videoInfo Parsed video info sent by Youtube
@param bool $detailed Caption track in video info
@return array Captions list | [
"Gets",
"caption",
"of",
"Youtube",
"video",
"and",
"returns",
"it",
"as",
"an",
"object"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L642-L665 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.parseCaption | protected function parseCaption($captionTrack)
{
if (!isset($captionTrack['u'])) return null;
try {
$response = $this->webClient->get($captionTrack['u']);
} catch (\Exception $e) {
if ($e instanceof ClientException && $e->hasResponse()) {
throw new YoutubeException($e->getResponse()->getReasonPhrase(), 3);
}
else
throw new YoutubeException($e->getMessage(), 3);
}
$caption = array();
$xml = simplexml_load_string($response->getBody());
foreach ($xml->text as $element) {
$item = array();
$item['text'] = html_entity_decode($element . "", ENT_QUOTES | ENT_XHTML);
$attributes = $element->attributes();
$item['start'] = floatval($attributes['start'] . "");
$item['duration'] = floatval(isset($attributes['dur']) ? $attributes['dur'] . "" : '1.0');
$item['end'] = $item['start'] + $item['duration'];
array_push($caption, $item);
}
$result = array();
$result['title'] = $captionTrack['n'];
$result['caption'] = $caption;
return ((object) $result);
} | php | protected function parseCaption($captionTrack)
{
if (!isset($captionTrack['u'])) return null;
try {
$response = $this->webClient->get($captionTrack['u']);
} catch (\Exception $e) {
if ($e instanceof ClientException && $e->hasResponse()) {
throw new YoutubeException($e->getResponse()->getReasonPhrase(), 3);
}
else
throw new YoutubeException($e->getMessage(), 3);
}
$caption = array();
$xml = simplexml_load_string($response->getBody());
foreach ($xml->text as $element) {
$item = array();
$item['text'] = html_entity_decode($element . "", ENT_QUOTES | ENT_XHTML);
$attributes = $element->attributes();
$item['start'] = floatval($attributes['start'] . "");
$item['duration'] = floatval(isset($attributes['dur']) ? $attributes['dur'] . "" : '1.0');
$item['end'] = $item['start'] + $item['duration'];
array_push($caption, $item);
}
$result = array();
$result['title'] = $captionTrack['n'];
$result['caption'] = $caption;
return ((object) $result);
} | [
"protected",
"function",
"parseCaption",
"(",
"$",
"captionTrack",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"captionTrack",
"[",
"'u'",
"]",
")",
")",
"return",
"null",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"webClient",
"->",
... | Gets caption of Youtube video and returns it as an object
@param object $captionTrack Detailed caption track
@return object Caption as an object | [
"Gets",
"caption",
"of",
"Youtube",
"video",
"and",
"returns",
"it",
"as",
"an",
"object"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L673-L701 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.formatCaption | protected function formatCaption($captionLines, $format=null)
{
$result = array();
$result['caption'] = '';
$result['extension'] = 'txt';
if ($format === null) $format = $this->captionFormat;
if ($format == 'srt') {
$result['extension'] = 'srt';
$sequence = 1;
foreach ($captionLines as $captionLine) {
$start = $this->parseFloatTime($captionLine['start']);
$end = $this->parseFloatTime($captionLine['end']);
$result['caption'] .= ($sequence++) . "\n";
$result['caption'] .= str_replace('.', ',', vsprintf('%02d:%02d:%02.3f', $start)) . ' --> ';
$result['caption'] .= str_replace('.', ',', vsprintf('%02d:%02d:%02.3f', $end)) . "\n";
$result['caption'] .= $captionLine['text'] . "\n\n";
}
$result['caption'] = trim($result['caption']);
} elseif ($format == 'sub') {
$result['extension'] = 'sub';
foreach ($captionLines as $captionLine) {
$result['caption'] .= '{' . intval($captionLine['start'] * $this->defaultFPS) . '}';
$result['caption'] .= '{' . intval($captionLine['end'] * $this->defaultFPS) . '}';
$result['caption'] .= $captionLine['text'] . "\n";
}
$result['caption'] = trim($result['caption']);
} elseif ($format == 'ass') {
$result['extension'] = 'ass';
$result['caption'] = <<<EOF
[Script Info]
ScriptType: v4.00+
Collisions: Normal
PlayDepth: 0
Timer: 100,0000
Video Aspect Ratio: 0
WrapStyle: 0
ScaledBorderAndShadow: no
[V4+ Styles]
Format: Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,StrikeOut,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding
Style: Default,Arial,16,&H00FFFFFF,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,2,10,10,10,0
Style: Top,Arial,16,&H00F9FFFF,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,8,10,10,10,0
Style: Mid,Arial,16,&H0000FFFF,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,5,10,10,10,0
Style: Bot,Arial,16,&H00F9FFF9,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,2,10,10,10,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
EOF;
foreach ($captionLines as $captionLine) {
$start = $this->parseFloatTime($captionLine['start']);
$end = $this->parseFloatTime($captionLine['end']);
$result['caption'] .= 'Dialogue: 0,';
$result['caption'] .= vsprintf('%d:%02d:%02.2f', $start) . ',';
$result['caption'] .= vsprintf('%d:%02d:%02.2f', $end) . ',Bot,,0000,0000,0000,,';
$result['caption'] .= $captionLine['text'] . "\n";
}
}
return ((object) $result);
} | php | protected function formatCaption($captionLines, $format=null)
{
$result = array();
$result['caption'] = '';
$result['extension'] = 'txt';
if ($format === null) $format = $this->captionFormat;
if ($format == 'srt') {
$result['extension'] = 'srt';
$sequence = 1;
foreach ($captionLines as $captionLine) {
$start = $this->parseFloatTime($captionLine['start']);
$end = $this->parseFloatTime($captionLine['end']);
$result['caption'] .= ($sequence++) . "\n";
$result['caption'] .= str_replace('.', ',', vsprintf('%02d:%02d:%02.3f', $start)) . ' --> ';
$result['caption'] .= str_replace('.', ',', vsprintf('%02d:%02d:%02.3f', $end)) . "\n";
$result['caption'] .= $captionLine['text'] . "\n\n";
}
$result['caption'] = trim($result['caption']);
} elseif ($format == 'sub') {
$result['extension'] = 'sub';
foreach ($captionLines as $captionLine) {
$result['caption'] .= '{' . intval($captionLine['start'] * $this->defaultFPS) . '}';
$result['caption'] .= '{' . intval($captionLine['end'] * $this->defaultFPS) . '}';
$result['caption'] .= $captionLine['text'] . "\n";
}
$result['caption'] = trim($result['caption']);
} elseif ($format == 'ass') {
$result['extension'] = 'ass';
$result['caption'] = <<<EOF
[Script Info]
ScriptType: v4.00+
Collisions: Normal
PlayDepth: 0
Timer: 100,0000
Video Aspect Ratio: 0
WrapStyle: 0
ScaledBorderAndShadow: no
[V4+ Styles]
Format: Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,StrikeOut,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding
Style: Default,Arial,16,&H00FFFFFF,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,2,10,10,10,0
Style: Top,Arial,16,&H00F9FFFF,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,8,10,10,10,0
Style: Mid,Arial,16,&H0000FFFF,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,5,10,10,10,0
Style: Bot,Arial,16,&H00F9FFF9,&H00FFFFFF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,3,0,2,10,10,10,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
EOF;
foreach ($captionLines as $captionLine) {
$start = $this->parseFloatTime($captionLine['start']);
$end = $this->parseFloatTime($captionLine['end']);
$result['caption'] .= 'Dialogue: 0,';
$result['caption'] .= vsprintf('%d:%02d:%02.2f', $start) . ',';
$result['caption'] .= vsprintf('%d:%02d:%02.2f', $end) . ',Bot,,0000,0000,0000,,';
$result['caption'] .= $captionLine['text'] . "\n";
}
}
return ((object) $result);
} | [
"protected",
"function",
"formatCaption",
"(",
"$",
"captionLines",
",",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"'caption'",
"]",
"=",
"''",
";",
"$",
"result",
"[",
"'extension'",
"]",
"... | Converts parsed caption track to desired caption format
@param array $captionLines Parsed caption
@param string $format Caption format, including "srt" (default), "sub", "ass"
@return object Converted caption and it's file extension | [
"Converts",
"parsed",
"caption",
"track",
"to",
"desired",
"caption",
"format"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L710-L776 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.downloadCaption | protected function downloadCaption($captions, $language, $filename)
{
if ($language === null) $language = $this->defaultCaptionLanguage;
if (!array_key_exists($language, $captions))
$captionData = array_shift($captions);
else
$captionData = $captions[$language];
$captionData = $this->parseCaption($captionData);
if ($captionData !== null) {
$captionData = $this->formatCaption($captionData->caption);
$filename = substr($filename, 0, strrpos($filename, '.')) . '.' . $captionData->extension;
$path = $this->path . DIRECTORY_SEPARATOR . $filename;
file_put_contents($path, $captionData->caption);
}
} | php | protected function downloadCaption($captions, $language, $filename)
{
if ($language === null) $language = $this->defaultCaptionLanguage;
if (!array_key_exists($language, $captions))
$captionData = array_shift($captions);
else
$captionData = $captions[$language];
$captionData = $this->parseCaption($captionData);
if ($captionData !== null) {
$captionData = $this->formatCaption($captionData->caption);
$filename = substr($filename, 0, strrpos($filename, '.')) . '.' . $captionData->extension;
$path = $this->path . DIRECTORY_SEPARATOR . $filename;
file_put_contents($path, $captionData->caption);
}
} | [
"protected",
"function",
"downloadCaption",
"(",
"$",
"captions",
",",
"$",
"language",
",",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"language",
"===",
"null",
")",
"$",
"language",
"=",
"$",
"this",
"->",
"defaultCaptionLanguage",
";",
"if",
"(",
"!"... | Downloads caption of the video in selected language
@param array $captions Captions data of video
@param string $language User selected language
@param string $filename Caption file name | [
"Downloads",
"caption",
"of",
"the",
"video",
"in",
"selected",
"language"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L785-L803 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.pathSafeFilename | public function pathSafeFilename($string)
{
$string = str_replace(
array_merge(range(chr(0), chr(31)), str_split("#%+&`‘/<>:\"|?*\x5C\x7F")),
' ',
trim($string)
);
$string = Utf8::filter($string);
$string = preg_replace('/\s{2,}/', ' ', $string);
$string = str_replace(array(' ', '%20'), '_', $string);
return $string;
} | php | public function pathSafeFilename($string)
{
$string = str_replace(
array_merge(range(chr(0), chr(31)), str_split("#%+&`‘/<>:\"|?*\x5C\x7F")),
' ',
trim($string)
);
$string = Utf8::filter($string);
$string = preg_replace('/\s{2,}/', ' ', $string);
$string = str_replace(array(' ', '%20'), '_', $string);
return $string;
} | [
"public",
"function",
"pathSafeFilename",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"array_merge",
"(",
"range",
"(",
"chr",
"(",
"0",
")",
",",
"chr",
"(",
"31",
")",
")",
",",
"str_split",
"(",
"\"#%+&`‘/<>:\\\"|?*\\x5C\\x7F\"... | Removes unsafe characters from file name
@param string $string Path unsafe file name
@return string Path Safe file name
@todo Use .net framework's Path.GetInvalidPathChars() for a better function | [
"Removes",
"unsafe",
"characters",
"from",
"file",
"name"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L813-L824 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.getExtension | protected function getExtension($mimetype)
{
$mime = new FlatRepository;
$extension = 'mp4';
$extensions = $mime->findExtensions($mimetype);
if (count($extensions))
$extension = $extensions[0];
return $extension;
} | php | protected function getExtension($mimetype)
{
$mime = new FlatRepository;
$extension = 'mp4';
$extensions = $mime->findExtensions($mimetype);
if (count($extensions))
$extension = $extensions[0];
return $extension;
} | [
"protected",
"function",
"getExtension",
"(",
"$",
"mimetype",
")",
"{",
"$",
"mime",
"=",
"new",
"FlatRepository",
";",
"$",
"extension",
"=",
"'mp4'",
";",
"$",
"extensions",
"=",
"$",
"mime",
"->",
"findExtensions",
"(",
"$",
"mimetype",
")",
";",
"if... | Returns file extension of a given mime type
@uses \Dflydev\ApacheMimeTypes\FlatRepository Mimetype parser library
@param string $mimetype Mime type
@return string File extension of given mime type. it will return "mp4" if no extension could be found | [
"Returns",
"file",
"extension",
"of",
"a",
"given",
"mime",
"type"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L833-L842 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.downloadFile | protected function downloadFile($url, $file, callable $onProgress, callable $onFinish)
{
$videoFile = fopen($file, 'a');
$options = array(
'sink' => $videoFile,
'verify' => false,
'timeout' => 0,
'connect_timeout' => 50,
'progress' => $onProgress,
'cookies' => new CookieJar(false, [['url' => 'https://www.youtube.com/watch?v=' . $this->videoId]])
);
$request = new Request('get', $url);
$promise = $this->webClient->sendAsync($request, $options);
$promise->then(
function (ResponseInterface $response) use ($videoFile, $file, $onFinish) {
fclose($videoFile);
$size = filesize($file);
$remained = intval((string)$response->getHeader('Content-Length')[0]);
$onFinish($size, $remained);
},
function (GuzzleException $e) {
if ($e instanceof ClientException && $e->hasResponse())
throw new YoutubeException($e->getResponse()->getReasonPhrase(), 4);
else
throw new YoutubeException($e->getMessage(), 4);
}
);
try {
$promise->wait();
} catch (ClientException $e) {
throw new YoutubeException('An error occurred when downloading video', 20, $e);
} catch (\RuntimeException $e) {
throw new YoutubeException('An error occurred when downloading video', 20, $e);
}
} | php | protected function downloadFile($url, $file, callable $onProgress, callable $onFinish)
{
$videoFile = fopen($file, 'a');
$options = array(
'sink' => $videoFile,
'verify' => false,
'timeout' => 0,
'connect_timeout' => 50,
'progress' => $onProgress,
'cookies' => new CookieJar(false, [['url' => 'https://www.youtube.com/watch?v=' . $this->videoId]])
);
$request = new Request('get', $url);
$promise = $this->webClient->sendAsync($request, $options);
$promise->then(
function (ResponseInterface $response) use ($videoFile, $file, $onFinish) {
fclose($videoFile);
$size = filesize($file);
$remained = intval((string)$response->getHeader('Content-Length')[0]);
$onFinish($size, $remained);
},
function (GuzzleException $e) {
if ($e instanceof ClientException && $e->hasResponse())
throw new YoutubeException($e->getResponse()->getReasonPhrase(), 4);
else
throw new YoutubeException($e->getMessage(), 4);
}
);
try {
$promise->wait();
} catch (ClientException $e) {
throw new YoutubeException('An error occurred when downloading video', 20, $e);
} catch (\RuntimeException $e) {
throw new YoutubeException('An error occurred when downloading video', 20, $e);
}
} | [
"protected",
"function",
"downloadFile",
"(",
"$",
"url",
",",
"$",
"file",
",",
"callable",
"$",
"onProgress",
",",
"callable",
"$",
"onFinish",
")",
"{",
"$",
"videoFile",
"=",
"fopen",
"(",
"$",
"file",
",",
"'a'",
")",
";",
"$",
"options",
"=",
"... | Just downloads the given url
@param string $url Url of file to download
@param string $file Path of file to save to
@param callable $onProgress Callback to be called on download progress
@param callable $onFinish Callback to be called on download complete
@throws YoutubeException | [
"Just",
"downloads",
"the",
"given",
"url"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L853-L891 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.download | public function download($itag=null, $resume=false, $caption=false)
{
if ($itag === null && $this->defaultItag !== null) $itag = $this->defaultItag;
if (!$this->isPlaylist) {
try {
$this->getVideoInfo(true);
$this->downloadVideo($itag, $resume, $caption);
} catch (YoutubeException $e) {
throw $e;
}
} else {
$i = 1;
foreach ($this->playlistInfo->video as $video)
{
$this->currentDownloadingVideoIndex = $i++;
$this->videoId = $video->encrypted_id;
try {
$this->getVideoInfo(true);
} catch (YoutubeException $e) {
throw $e;
}
try {
$this->downloadVideo($itag, $resume, $caption);
} catch (YoutubeException $e) {
throw $e;
}
}
}
} | php | public function download($itag=null, $resume=false, $caption=false)
{
if ($itag === null && $this->defaultItag !== null) $itag = $this->defaultItag;
if (!$this->isPlaylist) {
try {
$this->getVideoInfo(true);
$this->downloadVideo($itag, $resume, $caption);
} catch (YoutubeException $e) {
throw $e;
}
} else {
$i = 1;
foreach ($this->playlistInfo->video as $video)
{
$this->currentDownloadingVideoIndex = $i++;
$this->videoId = $video->encrypted_id;
try {
$this->getVideoInfo(true);
} catch (YoutubeException $e) {
throw $e;
}
try {
$this->downloadVideo($itag, $resume, $caption);
} catch (YoutubeException $e) {
throw $e;
}
}
}
} | [
"public",
"function",
"download",
"(",
"$",
"itag",
"=",
"null",
",",
"$",
"resume",
"=",
"false",
",",
"$",
"caption",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"itag",
"===",
"null",
"&&",
"$",
"this",
"->",
"defaultItag",
"!==",
"null",
")",
"$",
... | Downloads video or playlist videos by given itag
@throws YoutubeException If Video ID is wrong or video not exists anymore or it's not viewable anyhow
@param int $itag After calling {@see getVideoInfo()}, it returns various formats, each format has it's own itag. if no itag is passed or passed itag is not valid for the video, it will download the best quality of video
@param boolean $resume If it should resume download if an uncompleted file exists or should download from beginning
@param mixed $caption Caption language to download or null to download caption of default language. false to prevent download
@throws YoutubeException | [
"Downloads",
"video",
"or",
"playlist",
"videos",
"by",
"given",
"itag"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L903-L932 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.downloadVideo | protected function downloadVideo($itag=null, $resume=false, $caption=false)
{
if ($itag) {
foreach ($this->videoInfo->full_formats as $video) {
if ($video->itag == $itag) {
try {
$this->downloadFull($video->url, $video->filename, $resume);
$this->finalize($video->filename, $caption);
} catch (YoutubeException $e) {
throw $e;
}
return;
}
}
foreach ($this->videoInfo->adaptive_formats as $video) {
if ($video->itag == $itag) {
try {
$this->downloadAdaptive($video->url, $video->filename, $video->clen, $resume);
} catch (YoutubeException $e) {
throw $e;
}
$this->finalize($video->filename, $caption);
return;
}
}
}
if (count($this->videoInfo->full_formats) === 0) {
if (count($this->videoInfo->adaptive_formats) === 0)
throw new YoutubeException('There is no format for download', 32);
else {
$video = $this->videoInfo->adaptive_formats[0];
try {
$this->downloadAdaptive($video->url, $video->filename, $video->clen, $resume);
$this->finalize($video->filename, $caption);
} catch (YoutubeException $e) {
throw $e;
}
}
}
$video = $this->videoInfo->full_formats[0];
try {
$this->downloadFull($video->url, $video->filename, $resume);
$this->finalize($video->filename, $caption);
} catch (YoutubeException $e) {
throw $e;
}
} | php | protected function downloadVideo($itag=null, $resume=false, $caption=false)
{
if ($itag) {
foreach ($this->videoInfo->full_formats as $video) {
if ($video->itag == $itag) {
try {
$this->downloadFull($video->url, $video->filename, $resume);
$this->finalize($video->filename, $caption);
} catch (YoutubeException $e) {
throw $e;
}
return;
}
}
foreach ($this->videoInfo->adaptive_formats as $video) {
if ($video->itag == $itag) {
try {
$this->downloadAdaptive($video->url, $video->filename, $video->clen, $resume);
} catch (YoutubeException $e) {
throw $e;
}
$this->finalize($video->filename, $caption);
return;
}
}
}
if (count($this->videoInfo->full_formats) === 0) {
if (count($this->videoInfo->adaptive_formats) === 0)
throw new YoutubeException('There is no format for download', 32);
else {
$video = $this->videoInfo->adaptive_formats[0];
try {
$this->downloadAdaptive($video->url, $video->filename, $video->clen, $resume);
$this->finalize($video->filename, $caption);
} catch (YoutubeException $e) {
throw $e;
}
}
}
$video = $this->videoInfo->full_formats[0];
try {
$this->downloadFull($video->url, $video->filename, $resume);
$this->finalize($video->filename, $caption);
} catch (YoutubeException $e) {
throw $e;
}
} | [
"protected",
"function",
"downloadVideo",
"(",
"$",
"itag",
"=",
"null",
",",
"$",
"resume",
"=",
"false",
",",
"$",
"caption",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"itag",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"videoInfo",
"->",
"full_form... | Downloads selected video by given itag
@throws YoutubeException If Video ID is wrong or video not exists anymore or it's not viewable anyhow
@param int $itag After calling {@see getVideoInfo()}, it returns various formats, each format has it's own itag. if no itag is passed or passed itag is not valid for the video, it will download the best quality of video
@param boolean $resume If it should resume download if an uncompleted file exists or should download from beginning
@param mixed $caption Caption language to download or null to download caption of default language. false to prevent download
@throws YoutubeException | [
"Downloads",
"selected",
"video",
"by",
"given",
"itag"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L944-L994 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.finalize | public function finalize($filename, $caption)
{
$canEditFile = false;
$filePath = $this->path . DIRECTORY_SEPARATOR . $filename;
$file = null;
if ($this->mp4EditingEnabled && strtolower(pathinfo($filename, PATHINFO_EXTENSION)) == 'mp4') {
$file = new Mp4($filePath);
$canEditFile = true;
if (strtolower($this->captionFormat) == 'sub')
$this->defaultFPS = $file->getFPS();
}
if ($caption !== false && count($this->videoInfo->captions))
$this->downloadCaption($this->videoInfo->captions, $caption, $filename);
if ($canEditFile) {
try {
$response = $this->webClient->get($this->videoInfo->image['medium_quality']);
if ($response->getStatusCode() == 200)
$file->setCover($response->getBody());
} catch (\Exception $e) {}
$file->setTrackName($this->videoInfo->title);
$file->setArtist($this->videoInfo->author);
$videosCount = $this->isPlaylist ? count($this->playlistInfo->video) : 1;
if ($videosCount > 1)
$file->setTrackNumber($this->currentDownloadingVideoIndex, $videosCount);
$file->setSoftwareInformation('Downloaded by YoutubeDownloader https://is.gd/Youtubedownloader');
$file->setMediaType(MediaTypes::Movie);
$tempFilePath = $filePath . time();
copy($filePath, $tempFilePath); // Make backup of video in case something goes wrong
try {
$file->save();
unlink($tempFilePath);
} catch (\Zend_Media_Iso14496_Exception $e) {
$file = null;
rename($tempFilePath, $filePath); // Restore backup file in case of error
}
if ($file && $this->autoCloseEditedMp4Files) {
$file->__destruct();
$file = null;
}
}
$videosCount = $this->isPlaylist ? count($this->playlistInfo->video) : 1;
$onFinalized = $this->onFinalized;
$onFinalized($filePath, filesize($filePath), $this->currentDownloadingVideoIndex, $videosCount);
} | php | public function finalize($filename, $caption)
{
$canEditFile = false;
$filePath = $this->path . DIRECTORY_SEPARATOR . $filename;
$file = null;
if ($this->mp4EditingEnabled && strtolower(pathinfo($filename, PATHINFO_EXTENSION)) == 'mp4') {
$file = new Mp4($filePath);
$canEditFile = true;
if (strtolower($this->captionFormat) == 'sub')
$this->defaultFPS = $file->getFPS();
}
if ($caption !== false && count($this->videoInfo->captions))
$this->downloadCaption($this->videoInfo->captions, $caption, $filename);
if ($canEditFile) {
try {
$response = $this->webClient->get($this->videoInfo->image['medium_quality']);
if ($response->getStatusCode() == 200)
$file->setCover($response->getBody());
} catch (\Exception $e) {}
$file->setTrackName($this->videoInfo->title);
$file->setArtist($this->videoInfo->author);
$videosCount = $this->isPlaylist ? count($this->playlistInfo->video) : 1;
if ($videosCount > 1)
$file->setTrackNumber($this->currentDownloadingVideoIndex, $videosCount);
$file->setSoftwareInformation('Downloaded by YoutubeDownloader https://is.gd/Youtubedownloader');
$file->setMediaType(MediaTypes::Movie);
$tempFilePath = $filePath . time();
copy($filePath, $tempFilePath); // Make backup of video in case something goes wrong
try {
$file->save();
unlink($tempFilePath);
} catch (\Zend_Media_Iso14496_Exception $e) {
$file = null;
rename($tempFilePath, $filePath); // Restore backup file in case of error
}
if ($file && $this->autoCloseEditedMp4Files) {
$file->__destruct();
$file = null;
}
}
$videosCount = $this->isPlaylist ? count($this->playlistInfo->video) : 1;
$onFinalized = $this->onFinalized;
$onFinalized($filePath, filesize($filePath), $this->currentDownloadingVideoIndex, $videosCount);
} | [
"public",
"function",
"finalize",
"(",
"$",
"filename",
",",
"$",
"caption",
")",
"{",
"$",
"canEditFile",
"=",
"false",
";",
"$",
"filePath",
"=",
"$",
"this",
"->",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filename",
";",
"$",
"file",
"=",
"nul... | Finalizes downloaded file
@param string $filename Full name of file to save to
@param mixed $caption Caption language to download or null to download caption of default language. false to prevent download | [
"Finalizes",
"downloaded",
"file"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L1002-L1057 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.downloadFull | public function downloadFull($url, $file, $resume=false)
{
$file = $this->path . DIRECTORY_SEPARATOR . $file;
if (file_exists($file) && !$resume)
unlink($file);
$downloadedBytes = &$this->downloadedBytes;
$fileSize = &$this->fileSize;
$onProgress = &$this->onProgress;
$onComplete = &$this->onComplete;
$videosCount = $this->isPlaylist ? count($this->playlistInfo->video) : 1;
try {
$this->downloadFile(
$url, $file,
function ($downloadSize, $downloaded) use (&$downloadedBytes, &$fileSize, $onProgress, $videosCount) {
if (!$downloaded && !$downloadSize) return 1;
if ($downloadedBytes != $downloaded)
$onProgress($downloaded, $downloadSize, $this->currentDownloadingVideoIndex, $videosCount);
$downloadedBytes = $downloaded;
$fileSize = $downloadSize;
return 0;
},
function ($downloadSize) use ($onComplete, $file, $videosCount) {
$onComplete($file, $downloadSize, $this->currentDownloadingVideoIndex, $videosCount);
}
);
} catch (YoutubeException $e) {
throw $e;
}
} | php | public function downloadFull($url, $file, $resume=false)
{
$file = $this->path . DIRECTORY_SEPARATOR . $file;
if (file_exists($file) && !$resume)
unlink($file);
$downloadedBytes = &$this->downloadedBytes;
$fileSize = &$this->fileSize;
$onProgress = &$this->onProgress;
$onComplete = &$this->onComplete;
$videosCount = $this->isPlaylist ? count($this->playlistInfo->video) : 1;
try {
$this->downloadFile(
$url, $file,
function ($downloadSize, $downloaded) use (&$downloadedBytes, &$fileSize, $onProgress, $videosCount) {
if (!$downloaded && !$downloadSize) return 1;
if ($downloadedBytes != $downloaded)
$onProgress($downloaded, $downloadSize, $this->currentDownloadingVideoIndex, $videosCount);
$downloadedBytes = $downloaded;
$fileSize = $downloadSize;
return 0;
},
function ($downloadSize) use ($onComplete, $file, $videosCount) {
$onComplete($file, $downloadSize, $this->currentDownloadingVideoIndex, $videosCount);
}
);
} catch (YoutubeException $e) {
throw $e;
}
} | [
"public",
"function",
"downloadFull",
"(",
"$",
"url",
",",
"$",
"file",
",",
"$",
"resume",
"=",
"false",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
";",
"if",
"(",
"file_exists",
"(",
"$",
... | Downloads full_formats videos given by {@see getVideoInfo()}
@param string $url Video url given by {@see getVideoInfo()}
@param string $file Path of file to save to
@param boolean $resume If it should resume download if an uncompleted file exists or should download from beginning
@throws YoutubeException | [
"Downloads",
"full_formats",
"videos",
"given",
"by",
"{",
"@see",
"getVideoInfo",
"()",
"}"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L1067-L1098 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.enableMp4Editing | public function enableMp4Editing($enable, $autoClose=false)
{
$this->mp4EditingEnabled = !!$enable;
$this->autoCloseEditedMp4Files = !!$autoClose;
} | php | public function enableMp4Editing($enable, $autoClose=false)
{
$this->mp4EditingEnabled = !!$enable;
$this->autoCloseEditedMp4Files = !!$autoClose;
} | [
"public",
"function",
"enableMp4Editing",
"(",
"$",
"enable",
",",
"$",
"autoClose",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"mp4EditingEnabled",
"=",
"!",
"!",
"$",
"enable",
";",
"$",
"this",
"->",
"autoCloseEditedMp4Files",
"=",
"!",
"!",
"$",
"aut... | Sets default caption format
@param boolean $enable Enables or disables use of mp4 editing
@param boolean $autoClose Auto close edited Mp4 file (Underlying package has a bug. Use at your own risk) | [
"Sets",
"default",
"caption",
"format"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L1203-L1207 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/YoutubeDownloader.php | YoutubeDownloader.parseFloatTime | protected function parseFloatTime($time)
{
$result = array();
array_push($result, fmod($time, 60));
$time = intval($time / 60);
array_push($result, fmod($time, 60));
$time = intval($time / 60);
array_push($result, fmod($time, 60));
return array_reverse($result);
} | php | protected function parseFloatTime($time)
{
$result = array();
array_push($result, fmod($time, 60));
$time = intval($time / 60);
array_push($result, fmod($time, 60));
$time = intval($time / 60);
array_push($result, fmod($time, 60));
return array_reverse($result);
} | [
"protected",
"function",
"parseFloatTime",
"(",
"$",
"time",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"array_push",
"(",
"$",
"result",
",",
"fmod",
"(",
"$",
"time",
",",
"60",
")",
")",
";",
"$",
"time",
"=",
"intval",
"(",
"$",
"t... | Sets downloaded videos path
@param float $time Time in float
@return array Time array [hours, minutes, seconds] | [
"Sets",
"downloaded",
"videos",
"path"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/YoutubeDownloader.php#L1215-L1224 |
masihyeganeh/YoutubeDownloader | Masih/YoutubeDownloader/Mp4/Mp4.php | Mp4.setGenre | public function setGenre($genre) {
if (is_numeric($genre)) {
$this->addOrChangeMetaData('gnre', $this->number($genre + 1, 16));
// $this->addOrChangeMetaData('gnre', ID3v1Genres::of($genre));
} else
$this->addOrChangeMetaData('gen', $genre);
} | php | public function setGenre($genre) {
if (is_numeric($genre)) {
$this->addOrChangeMetaData('gnre', $this->number($genre + 1, 16));
// $this->addOrChangeMetaData('gnre', ID3v1Genres::of($genre));
} else
$this->addOrChangeMetaData('gen', $genre);
} | [
"public",
"function",
"setGenre",
"(",
"$",
"genre",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"genre",
")",
")",
"{",
"$",
"this",
"->",
"addOrChangeMetaData",
"(",
"'gnre'",
",",
"$",
"this",
"->",
"number",
"(",
"$",
"genre",
"+",
"1",
",",
"... | ID3v1Genres int or string | [
"ID3v1Genres",
"int",
"or",
"string"
] | train | https://github.com/masihyeganeh/YoutubeDownloader/blob/0687ca48535596dc202189774a0e1ee203dc2347/Masih/YoutubeDownloader/Mp4/Mp4.php#L120-L126 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.requestIsValid | private function requestIsValid(): bool
{
return $this->request->has(self::OPENID_ASSOC_HANDLE)
&& $this->request->has(self::OPENID_SIGNED)
&& $this->request->has(self::OPENID_SIG);
} | php | private function requestIsValid(): bool
{
return $this->request->has(self::OPENID_ASSOC_HANDLE)
&& $this->request->has(self::OPENID_SIGNED)
&& $this->request->has(self::OPENID_SIG);
} | [
"private",
"function",
"requestIsValid",
"(",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"has",
"(",
"self",
"::",
"OPENID_ASSOC_HANDLE",
")",
"&&",
"$",
"this",
"->",
"request",
"->",
"has",
"(",
"self",
"::",
"OPENID_SIGNED",
... | Validates if the request object has required stream attributes.
@return bool | [
"Validates",
"if",
"the",
"request",
"object",
"has",
"required",
"stream",
"attributes",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L98-L103 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.validate | public function validate(): bool
{
if (! $this->requestIsValid()) {
return false;
}
$requestOptions = $this->getDefaultRequestOptions();
$customOptions = $this->getCustomRequestOptions();
if (! empty($customOptions) && is_array($customOptions)) {
$requestOptions = array_merge($requestOptions, $customOptions);
}
$response = $this->guzzleClient->request('POST', self::OPENID_URL, $requestOptions);
$results = $this->parseResults($response->getBody()->getContents());
$this->parseSteamID();
$this->parseInfo();
return $results->is_valid == 'true';
} | php | public function validate(): bool
{
if (! $this->requestIsValid()) {
return false;
}
$requestOptions = $this->getDefaultRequestOptions();
$customOptions = $this->getCustomRequestOptions();
if (! empty($customOptions) && is_array($customOptions)) {
$requestOptions = array_merge($requestOptions, $customOptions);
}
$response = $this->guzzleClient->request('POST', self::OPENID_URL, $requestOptions);
$results = $this->parseResults($response->getBody()->getContents());
$this->parseSteamID();
$this->parseInfo();
return $results->is_valid == 'true';
} | [
"public",
"function",
"validate",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"requestIsValid",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"requestOptions",
"=",
"$",
"this",
"->",
"getDefaultRequestOptions",
"(",
")",
";"... | Checks the steam login.
@return bool
@throws GuzzleException | [
"Checks",
"the",
"steam",
"login",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L111-L132 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.getParams | public function getParams(): array
{
$params = [
'openid.assoc_handle' => $this->request->get(self::OPENID_ASSOC_HANDLE),
'openid.signed' => $this->request->get(self::OPENID_SIGNED),
'openid.sig' => $this->request->get(self::OPENID_SIG),
'openid.ns' => self::OPENID_NS,
'openid.mode' => 'check_authentication',
];
$signedParams = explode(',', $this->request->get(self::OPENID_SIGNED));
foreach ($signedParams as $item) {
$value = $this->request->get('openid_'.str_replace('.', '_', $item));
$params['openid.'.$item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
}
return $params;
} | php | public function getParams(): array
{
$params = [
'openid.assoc_handle' => $this->request->get(self::OPENID_ASSOC_HANDLE),
'openid.signed' => $this->request->get(self::OPENID_SIGNED),
'openid.sig' => $this->request->get(self::OPENID_SIG),
'openid.ns' => self::OPENID_NS,
'openid.mode' => 'check_authentication',
];
$signedParams = explode(',', $this->request->get(self::OPENID_SIGNED));
foreach ($signedParams as $item) {
$value = $this->request->get('openid_'.str_replace('.', '_', $item));
$params['openid.'.$item] = get_magic_quotes_gpc() ? stripslashes($value) : $value;
}
return $params;
} | [
"public",
"function",
"getParams",
"(",
")",
":",
"array",
"{",
"$",
"params",
"=",
"[",
"'openid.assoc_handle'",
"=>",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"self",
"::",
"OPENID_ASSOC_HANDLE",
")",
",",
"'openid.signed'",
"=>",
"$",
"this",
"->... | Get param list for openId validation.
@return array | [
"Get",
"param",
"list",
"for",
"openId",
"validation",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L139-L157 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.parseResults | public function parseResults($results): Fluent
{
$parsed = [];
$lines = explode("\n", $results);
foreach ($lines as $line) {
if (empty($line)) {
continue;
}
$line = explode(':', $line, 2);
$parsed[$line[0]] = $line[1];
}
return new Fluent($parsed);
} | php | public function parseResults($results): Fluent
{
$parsed = [];
$lines = explode("\n", $results);
foreach ($lines as $line) {
if (empty($line)) {
continue;
}
$line = explode(':', $line, 2);
$parsed[$line[0]] = $line[1];
}
return new Fluent($parsed);
} | [
"public",
"function",
"parseResults",
"(",
"$",
"results",
")",
":",
"Fluent",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"results",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")"... | Parse openID response to fluent object.
@param string $results openid response body
@return Fluent | [
"Parse",
"openID",
"response",
"to",
"fluent",
"object",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L166-L181 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.buildUrl | private function buildUrl($return = null): string
{
if (is_null($return)) {
$return = url('/', [], Config::get('steam-auth.https'));
}
if (! is_null($return) && ! $this->validateUrl($return)) {
throw new RuntimeException('The return URL must be a valid URL with a URI scheme or http or https.');
}
$realm = Config::get('steam-auth.realm', $this->request->server('HTTP_HOST'));
$params = [
'openid.ns' => self::OPENID_NS,
'openid.mode' => 'checkid_setup',
'openid.return_to' => $return,
'openid.realm' => (Config::get('steam-auth.https') ? 'https' : 'http').'://'.$realm,
'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
];
return self::OPENID_URL.'?'.http_build_query($params, '', '&');
} | php | private function buildUrl($return = null): string
{
if (is_null($return)) {
$return = url('/', [], Config::get('steam-auth.https'));
}
if (! is_null($return) && ! $this->validateUrl($return)) {
throw new RuntimeException('The return URL must be a valid URL with a URI scheme or http or https.');
}
$realm = Config::get('steam-auth.realm', $this->request->server('HTTP_HOST'));
$params = [
'openid.ns' => self::OPENID_NS,
'openid.mode' => 'checkid_setup',
'openid.return_to' => $return,
'openid.realm' => (Config::get('steam-auth.https') ? 'https' : 'http').'://'.$realm,
'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
];
return self::OPENID_URL.'?'.http_build_query($params, '', '&');
} | [
"private",
"function",
"buildUrl",
"(",
"$",
"return",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"is_null",
"(",
"$",
"return",
")",
")",
"{",
"$",
"return",
"=",
"url",
"(",
"'/'",
",",
"[",
"]",
",",
"Config",
"::",
"get",
"(",
"'steam-a... | Build the Steam login URL.
@param string|null $return A custom return to URL
@return string | [
"Build",
"the",
"Steam",
"login",
"URL",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L206-L226 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.parseSteamID | public function parseSteamID(): void
{
preg_match(
'#^https?://steamcommunity.com/openid/id/([0-9]{17,25})#',
$this->request->get('openid_claimed_id'),
$matches
);
$this->steamId = is_numeric($matches[1]) ? $matches[1] : 0;
} | php | public function parseSteamID(): void
{
preg_match(
'#^https?://steamcommunity.com/openid/id/([0-9]{17,25})#',
$this->request->get('openid_claimed_id'),
$matches
);
$this->steamId = is_numeric($matches[1]) ? $matches[1] : 0;
} | [
"public",
"function",
"parseSteamID",
"(",
")",
":",
"void",
"{",
"preg_match",
"(",
"'#^https?://steamcommunity.com/openid/id/([0-9]{17,25})#'",
",",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'openid_claimed_id'",
")",
",",
"$",
"matches",
")",
";",
"$",
... | Parse the steamID from the OpenID response.
@return void | [
"Parse",
"the",
"steamID",
"from",
"the",
"OpenID",
"response",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L255-L263 |
invisnik/laravel-steam-auth | src/SteamAuth.php | SteamAuth.parseInfo | public function parseInfo(): void
{
if (is_null($this->steamId)) {
return;
}
if (empty(Config::get('steam-auth.api_key'))) {
throw new RuntimeException('The Steam API key has not been specified.');
}
$response = $this->guzzleClient->request(
'GET',
sprintf(self::STEAM_INFO_URL, Config::get('steam-auth.api_key'), $this->steamId)
);
$json = json_decode($response->getBody(), true);
$this->steamInfo = new SteamInfo($json['response']['players'][0]);
} | php | public function parseInfo(): void
{
if (is_null($this->steamId)) {
return;
}
if (empty(Config::get('steam-auth.api_key'))) {
throw new RuntimeException('The Steam API key has not been specified.');
}
$response = $this->guzzleClient->request(
'GET',
sprintf(self::STEAM_INFO_URL, Config::get('steam-auth.api_key'), $this->steamId)
);
$json = json_decode($response->getBody(), true);
$this->steamInfo = new SteamInfo($json['response']['players'][0]);
} | [
"public",
"function",
"parseInfo",
"(",
")",
":",
"void",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"steamId",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"Config",
"::",
"get",
"(",
"'steam-auth.api_key'",
")",
")",
")",
"... | Get user data from steam api.
@return void
@throws GuzzleException | [
"Get",
"user",
"data",
"from",
"steam",
"api",
"."
] | train | https://github.com/invisnik/laravel-steam-auth/blob/10fd44efbaeddc43fbe1331737b532fef2afe557/src/SteamAuth.php#L271-L288 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.fromText | public static function fromText(string $wkt, int $srid = 0) : Geometry
{
return new self($wkt, false, $srid);
} | php | public static function fromText(string $wkt, int $srid = 0) : Geometry
{
return new self($wkt, false, $srid);
} | [
"public",
"static",
"function",
"fromText",
"(",
"string",
"$",
"wkt",
",",
"int",
"$",
"srid",
"=",
"0",
")",
":",
"Geometry",
"{",
"return",
"new",
"self",
"(",
"$",
"wkt",
",",
"false",
",",
"$",
"srid",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L100-L103 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.fromBinary | public static function fromBinary(string $wkb, int $srid = 0) : Geometry
{
return new self($wkb, true, $srid);
} | php | public static function fromBinary(string $wkb, int $srid = 0) : Geometry
{
return new self($wkb, true, $srid);
} | [
"public",
"static",
"function",
"fromBinary",
"(",
"string",
"$",
"wkb",
",",
"int",
"$",
"srid",
"=",
"0",
")",
":",
"Geometry",
"{",
"return",
"new",
"self",
"(",
"$",
"wkb",
",",
"true",
",",
"$",
"srid",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L108-L111 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.asText | public function asText() : string
{
if (! $this->proxyIsBinary) {
return $this->proxyData;
}
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->asText();
} | php | public function asText() : string
{
if (! $this->proxyIsBinary) {
return $this->proxyData;
}
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->asText();
} | [
"public",
"function",
"asText",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"proxyIsBinary",
")",
"{",
"return",
"$",
"this",
"->",
"proxyData",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L124-L135 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.asBinary | public function asBinary() : string
{
if ($this->proxyIsBinary) {
return $this->proxyData;
}
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->asBinary();
} | php | public function asBinary() : string
{
if ($this->proxyIsBinary) {
return $this->proxyData;
}
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->asBinary();
} | [
"public",
"function",
"asBinary",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyIsBinary",
")",
"{",
"return",
"$",
"this",
"->",
"proxyData",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L140-L151 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.x | public function x() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->x();
} | php | public function x() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->x();
} | [
"public",
"function",
"x",
"(",
")",
":",
"?",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"x",
"(",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L157-L164 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.y | public function y() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->y();
} | php | public function y() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->y();
} | [
"public",
"function",
"y",
"(",
")",
":",
"?",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"y",
"(",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L169-L176 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.z | public function z() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->z();
} | php | public function z() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->z();
} | [
"public",
"function",
"z",
"(",
")",
":",
"?",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"z",
"(",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L181-L188 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.m | public function m() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->m();
} | php | public function m() : ?float
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->m();
} | [
"public",
"function",
"m",
"(",
")",
":",
"?",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"m",
"(",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L193-L200 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.swapXY | public function swapXY() : \Brick\Geo\Geometry
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->swapXY();
} | php | public function swapXY() : \Brick\Geo\Geometry
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->swapXY();
} | [
"public",
"function",
"swapXY",
"(",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Geometry",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L217-L224 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.count | public function count() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->count();
} | php | public function count() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->count();
} | [
"public",
"function",
"count",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"count",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L229-L236 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.coordinateDimension | public function coordinateDimension() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->coordinateDimension();
} | php | public function coordinateDimension() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->coordinateDimension();
} | [
"public",
"function",
"coordinateDimension",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"coordina... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L253-L260 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.spatialDimension | public function spatialDimension() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->spatialDimension();
} | php | public function spatialDimension() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->spatialDimension();
} | [
"public",
"function",
"spatialDimension",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"spatialDime... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L265-L272 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.isEmpty | public function isEmpty() : bool
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->isEmpty();
} | php | public function isEmpty() : bool
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->isEmpty();
} | [
"public",
"function",
"isEmpty",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"isEmpty",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L277-L284 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.is3D | public function is3D() : bool
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->is3D();
} | php | public function is3D() : bool
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->is3D();
} | [
"public",
"function",
"is3D",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"is3D",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L289-L296 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.isMeasured | public function isMeasured() : bool
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->isMeasured();
} | php | public function isMeasured() : bool
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->isMeasured();
} | [
"public",
"function",
"isMeasured",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"isMeasured",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L301-L308 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.coordinateSystem | public function coordinateSystem() : \Brick\Geo\CoordinateSystem
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->coordinateSystem();
} | php | public function coordinateSystem() : \Brick\Geo\CoordinateSystem
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->coordinateSystem();
} | [
"public",
"function",
"coordinateSystem",
"(",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"CoordinateSystem",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L313-L320 |
brick/geo | src/Proxy/PointProxy.php | PointProxy.withSRID | public function withSRID(int $srid) : \Brick\Geo\Geometry
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->withSRID($srid);
} | php | public function withSRID(int $srid) : \Brick\Geo\Geometry
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->withSRID($srid);
} | [
"public",
"function",
"withSRID",
"(",
"int",
"$",
"srid",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Geometry",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/PointProxy.php#L325-L332 |
brick/geo | src/IO/EWKTReader.php | EWKTReader.read | public function read(string $ewkt) : Geometry
{
$parser = new EWKTParser(strtoupper($ewkt));
$srid = $parser->getOptionalSRID();
$geometry = $this->readGeometry($parser, $srid);
if (! $parser->isEndOfStream()) {
throw GeometryIOException::invalidEWKT();
}
return $geometry;
} | php | public function read(string $ewkt) : Geometry
{
$parser = new EWKTParser(strtoupper($ewkt));
$srid = $parser->getOptionalSRID();
$geometry = $this->readGeometry($parser, $srid);
if (! $parser->isEndOfStream()) {
throw GeometryIOException::invalidEWKT();
}
return $geometry;
} | [
"public",
"function",
"read",
"(",
"string",
"$",
"ewkt",
")",
":",
"Geometry",
"{",
"$",
"parser",
"=",
"new",
"EWKTParser",
"(",
"strtoupper",
"(",
"$",
"ewkt",
")",
")",
";",
"$",
"srid",
"=",
"$",
"parser",
"->",
"getOptionalSRID",
"(",
")",
";",... | @param string $ewkt The EWKT to read.
@return Geometry
@throws GeometryIOException | [
"@param",
"string",
"$ewkt",
"The",
"EWKT",
"to",
"read",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/EWKTReader.php#L22-L33 |
brick/geo | src/IO/EWKTParser.php | EWKTParser.getRegex | protected function getRegex() : array
{
return [
self::T_SRID => self::REGEX_SRID,
self::T_WORD => self::REGEX_WORD,
self::T_NUMBER => self::REGEX_NUMBER,
];
} | php | protected function getRegex() : array
{
return [
self::T_SRID => self::REGEX_SRID,
self::T_WORD => self::REGEX_WORD,
self::T_NUMBER => self::REGEX_NUMBER,
];
} | [
"protected",
"function",
"getRegex",
"(",
")",
":",
"array",
"{",
"return",
"[",
"self",
"::",
"T_SRID",
"=>",
"self",
"::",
"REGEX_SRID",
",",
"self",
"::",
"T_WORD",
"=>",
"self",
"::",
"REGEX_WORD",
",",
"self",
"::",
"T_NUMBER",
"=>",
"self",
"::",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/EWKTParser.php#L21-L28 |
brick/geo | src/Exception/CoordinateSystemException.php | CoordinateSystemException.sridMix | public static function sridMix(Geometry $reference, Geometry $culprit) : CoordinateSystemException
{
return new CoordinateSystemException(sprintf(
'SRID mix: %s with SRID %d cannot contain %s with SRID %d.',
$reference->geometryType(),
$reference->SRID(),
$culprit->geometryType(),
$culprit->SRID()
));
} | php | public static function sridMix(Geometry $reference, Geometry $culprit) : CoordinateSystemException
{
return new CoordinateSystemException(sprintf(
'SRID mix: %s with SRID %d cannot contain %s with SRID %d.',
$reference->geometryType(),
$reference->SRID(),
$culprit->geometryType(),
$culprit->SRID()
));
} | [
"public",
"static",
"function",
"sridMix",
"(",
"Geometry",
"$",
"reference",
",",
"Geometry",
"$",
"culprit",
")",
":",
"CoordinateSystemException",
"{",
"return",
"new",
"CoordinateSystemException",
"(",
"sprintf",
"(",
"'SRID mix: %s with SRID %d cannot contain %s with... | @param Geometry $reference
@param Geometry $culprit
@return CoordinateSystemException | [
"@param",
"Geometry",
"$reference",
"@param",
"Geometry",
"$culprit"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Exception/CoordinateSystemException.php#L20-L29 |
brick/geo | src/Exception/CoordinateSystemException.php | CoordinateSystemException.dimensionalityMix | public static function dimensionalityMix(Geometry $reference, Geometry $culprit) : CoordinateSystemException
{
return new CoordinateSystemException(sprintf(
'Dimensionality mix: %s %s cannot contain %s %s.',
$reference->geometryType(),
$reference->coordinateSystem()->coordinateName(),
$culprit->geometryType(),
$culprit->coordinateSystem()->coordinateName()
));
} | php | public static function dimensionalityMix(Geometry $reference, Geometry $culprit) : CoordinateSystemException
{
return new CoordinateSystemException(sprintf(
'Dimensionality mix: %s %s cannot contain %s %s.',
$reference->geometryType(),
$reference->coordinateSystem()->coordinateName(),
$culprit->geometryType(),
$culprit->coordinateSystem()->coordinateName()
));
} | [
"public",
"static",
"function",
"dimensionalityMix",
"(",
"Geometry",
"$",
"reference",
",",
"Geometry",
"$",
"culprit",
")",
":",
"CoordinateSystemException",
"{",
"return",
"new",
"CoordinateSystemException",
"(",
"sprintf",
"(",
"'Dimensionality mix: %s %s cannot conta... | @param Geometry $reference
@param Geometry $culprit
@return CoordinateSystemException | [
"@param",
"Geometry",
"$reference",
"@param",
"Geometry",
"$culprit"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Exception/CoordinateSystemException.php#L37-L46 |
brick/geo | src/Geometry.php | Geometry.fromText | public static function fromText(string $wkt, int $srid = 0) : Geometry
{
static $wktReader;
if ($wktReader === null) {
$wktReader = new WKTReader();
}
$geometry = $wktReader->read($wkt, $srid);
if (! $geometry instanceof static) {
throw UnexpectedGeometryException::unexpectedGeometryType(static::class, $geometry);
}
return $geometry;
} | php | public static function fromText(string $wkt, int $srid = 0) : Geometry
{
static $wktReader;
if ($wktReader === null) {
$wktReader = new WKTReader();
}
$geometry = $wktReader->read($wkt, $srid);
if (! $geometry instanceof static) {
throw UnexpectedGeometryException::unexpectedGeometryType(static::class, $geometry);
}
return $geometry;
} | [
"public",
"static",
"function",
"fromText",
"(",
"string",
"$",
"wkt",
",",
"int",
"$",
"srid",
"=",
"0",
")",
":",
"Geometry",
"{",
"static",
"$",
"wktReader",
";",
"if",
"(",
"$",
"wktReader",
"===",
"null",
")",
"{",
"$",
"wktReader",
"=",
"new",
... | Builds a Geometry from a WKT representation.
If the resulting geometry is valid but is not an instance of the class this method is called on,
for example passing a Polygon WKT to Point::fromText(), an exception is thrown.
@param string $wkt The Well-Known Text representation.
@param int $srid The optional SRID to use.
@return static
@throws GeometryIOException If the given string is not a valid WKT representation.
@throws CoordinateSystemException If the WKT contains mixed coordinate systems.
@throws InvalidGeometryException If the WKT represents an invalid geometry.
@throws UnexpectedGeometryException If the resulting geometry is not an instance of the current class. | [
"Builds",
"a",
"Geometry",
"from",
"a",
"WKT",
"representation",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L84-L99 |
brick/geo | src/Geometry.php | Geometry.fromBinary | public static function fromBinary(string $wkb, int $srid = 0) : Geometry
{
static $wkbReader;
if ($wkbReader === null) {
$wkbReader = new WKBReader();
}
$geometry = $wkbReader->read($wkb, $srid);
if (! $geometry instanceof static) {
throw UnexpectedGeometryException::unexpectedGeometryType(static::class, $geometry);
}
return $geometry;
} | php | public static function fromBinary(string $wkb, int $srid = 0) : Geometry
{
static $wkbReader;
if ($wkbReader === null) {
$wkbReader = new WKBReader();
}
$geometry = $wkbReader->read($wkb, $srid);
if (! $geometry instanceof static) {
throw UnexpectedGeometryException::unexpectedGeometryType(static::class, $geometry);
}
return $geometry;
} | [
"public",
"static",
"function",
"fromBinary",
"(",
"string",
"$",
"wkb",
",",
"int",
"$",
"srid",
"=",
"0",
")",
":",
"Geometry",
"{",
"static",
"$",
"wkbReader",
";",
"if",
"(",
"$",
"wkbReader",
"===",
"null",
")",
"{",
"$",
"wkbReader",
"=",
"new"... | Builds a Geometry from a WKB representation.
If the resulting geometry is valid but is not an instance of the class this method is called on,
for example passing a Polygon WKB to Point::fromBinary(), an exception is thrown.
@param string $wkb The Well-Known Binary representation.
@param int $srid The optional SRID to use.
@return static
@throws GeometryIOException If the given string is not a valid WKB representation.
@throws CoordinateSystemException If the WKB contains mixed coordinate systems.
@throws InvalidGeometryException If the WKB represents an invalid geometry.
@throws UnexpectedGeometryException If the resulting geometry is not an instance of the current class. | [
"Builds",
"a",
"Geometry",
"from",
"a",
"WKB",
"representation",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L117-L132 |
brick/geo | src/Geometry.php | Geometry.asText | public function asText() : string
{
static $wktWriter;
if ($wktWriter === null) {
$wktWriter = new WKTWriter();
}
return $wktWriter->write($this);
} | php | public function asText() : string
{
static $wktWriter;
if ($wktWriter === null) {
$wktWriter = new WKTWriter();
}
return $wktWriter->write($this);
} | [
"public",
"function",
"asText",
"(",
")",
":",
"string",
"{",
"static",
"$",
"wktWriter",
";",
"if",
"(",
"$",
"wktWriter",
"===",
"null",
")",
"{",
"$",
"wktWriter",
"=",
"new",
"WKTWriter",
"(",
")",
";",
"}",
"return",
"$",
"wktWriter",
"->",
"wri... | Returns the WKT representation of this geometry.
@noproxy
@return string | [
"Returns",
"the",
"WKT",
"representation",
"of",
"this",
"geometry",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L226-L235 |
brick/geo | src/Geometry.php | Geometry.asBinary | public function asBinary() : string
{
static $wkbWriter;
if ($wkbWriter === null) {
$wkbWriter = new WKBWriter();
}
return $wkbWriter->write($this);
} | php | public function asBinary() : string
{
static $wkbWriter;
if ($wkbWriter === null) {
$wkbWriter = new WKBWriter();
}
return $wkbWriter->write($this);
} | [
"public",
"function",
"asBinary",
"(",
")",
":",
"string",
"{",
"static",
"$",
"wkbWriter",
";",
"if",
"(",
"$",
"wkbWriter",
"===",
"null",
")",
"{",
"$",
"wkbWriter",
"=",
"new",
"WKBWriter",
"(",
")",
";",
"}",
"return",
"$",
"wkbWriter",
"->",
"w... | Returns the WKB representation of this geometry.
@noproxy
@return string | [
"Returns",
"the",
"WKB",
"representation",
"of",
"this",
"geometry",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L244-L253 |
brick/geo | src/Geometry.php | Geometry.relate | public function relate(Geometry $geometry, string $matrix) : bool
{
return GeometryEngineRegistry::get()->relate($this, $geometry, $matrix);
} | php | public function relate(Geometry $geometry, string $matrix) : bool
{
return GeometryEngineRegistry::get()->relate($this, $geometry, $matrix);
} | [
"public",
"function",
"relate",
"(",
"Geometry",
"$",
"geometry",
",",
"string",
"$",
"matrix",
")",
":",
"bool",
"{",
"return",
"GeometryEngineRegistry",
"::",
"get",
"(",
")",
"->",
"relate",
"(",
"$",
"this",
",",
"$",
"geometry",
",",
"$",
"matrix",
... | Returns whether this geometry is spatially related to another geometry.
This method tests for intersections between the interior, boundary and exterior of the
two geometries as specified by the values in the DE-9IM matrix pattern.
This is especially useful for testing compound checks of intersection, crosses, etc. in one step.
@see http://en.wikipedia.org/wiki/DE-9IM
@noproxy
@param Geometry $geometry
@param string $matrix
@return bool
@throws GeometryEngineException If the operation is not supported by the geometry engine. | [
"Returns",
"whether",
"this",
"geometry",
"is",
"spatially",
"related",
"to",
"another",
"geometry",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L500-L503 |
brick/geo | src/Geometry.php | Geometry.locateBetween | public function locateBetween(float $mStart, float $mEnd) : Geometry
{
return GeometryEngineRegistry::get()->locateBetween($this, $mStart, $mEnd);
} | php | public function locateBetween(float $mStart, float $mEnd) : Geometry
{
return GeometryEngineRegistry::get()->locateBetween($this, $mStart, $mEnd);
} | [
"public",
"function",
"locateBetween",
"(",
"float",
"$",
"mStart",
",",
"float",
"$",
"mEnd",
")",
":",
"Geometry",
"{",
"return",
"GeometryEngineRegistry",
"::",
"get",
"(",
")",
"->",
"locateBetween",
"(",
"$",
"this",
",",
"$",
"mStart",
",",
"$",
"m... | Returns a derived geometry collection value that matches the specified range of m coordinate values inclusively.
@noproxy
@param float $mStart
@param float $mEnd
@return Geometry
@throws GeometryEngineException If the operation is not supported by the geometry engine. | [
"Returns",
"a",
"derived",
"geometry",
"collection",
"value",
"that",
"matches",
"the",
"specified",
"range",
"of",
"m",
"coordinate",
"values",
"inclusively",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L533-L536 |
brick/geo | src/Geometry.php | Geometry.withSRID | public function withSRID(int $srid) : Geometry
{
if ($srid === $this->SRID()) {
return $this;
}
$that = clone $this;
$that->coordinateSystem = $that->coordinateSystem->withSRID($srid);
return $that;
} | php | public function withSRID(int $srid) : Geometry
{
if ($srid === $this->SRID()) {
return $this;
}
$that = clone $this;
$that->coordinateSystem = $that->coordinateSystem->withSRID($srid);
return $that;
} | [
"public",
"function",
"withSRID",
"(",
"int",
"$",
"srid",
")",
":",
"Geometry",
"{",
"if",
"(",
"$",
"srid",
"===",
"$",
"this",
"->",
"SRID",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"that",
"=",
"clone",
"$",
"this",
";",
"$... | Returns a copy of this Geometry, with the SRID altered.
@param int $srid
@return static | [
"Returns",
"a",
"copy",
"of",
"this",
"Geometry",
"with",
"the",
"SRID",
"altered",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Geometry.php#L734-L744 |
brick/geo | src/Proxy/GeometryCollectionProxy.php | GeometryCollectionProxy.numGeometries | public function numGeometries() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->numGeometries();
} | php | public function numGeometries() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->numGeometries();
} | [
"public",
"function",
"numGeometries",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"numGeometries"... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/GeometryCollectionProxy.php#L157-L164 |
brick/geo | src/Proxy/GeometryCollectionProxy.php | GeometryCollectionProxy.geometryN | public function geometryN(int $n) : \Brick\Geo\Geometry
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->geometryN($n);
} | php | public function geometryN(int $n) : \Brick\Geo\Geometry
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->geometryN($n);
} | [
"public",
"function",
"geometryN",
"(",
"int",
"$",
"n",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Geometry",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/GeometryCollectionProxy.php#L169-L176 |
brick/geo | src/Proxy/GeometryCollectionProxy.php | GeometryCollectionProxy.dimension | public function dimension() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->dimension();
} | php | public function dimension() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->dimension();
} | [
"public",
"function",
"dimension",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"dimension",
"(",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/GeometryCollectionProxy.php#L193-L200 |
brick/geo | src/Doctrine/Functions/EarthDistanceFunction.php | EarthDistanceFunction.getSql | public function getSql(SqlWalker $s)
{
$platform = $s->getConnection()->getDatabasePlatform()->getName();
switch ($platform) {
case 'postgresql':
return sprintf(
'ST_Distance_Sphere(%s, %s)',
$this->arg1->dispatch($s),
$this->arg2->dispatch($s)
);
case 'sqlite':
return sprintf(
'GreatCircleLength(MakeLine(%s, %s))',
$this->arg1->dispatch($s),
$this->arg2->dispatch($s)
);
}
return sprintf(
self::FORMULA,
self::EARTH_RADIUS,
$this->y($this->arg1->dispatch($s)),
$this->y($this->arg2->dispatch($s)),
$this->y($this->arg1->dispatch($s)),
$this->y($this->arg2->dispatch($s)),
$this->x($this->arg2->dispatch($s)),
$this->x($this->arg1->dispatch($s))
);
} | php | public function getSql(SqlWalker $s)
{
$platform = $s->getConnection()->getDatabasePlatform()->getName();
switch ($platform) {
case 'postgresql':
return sprintf(
'ST_Distance_Sphere(%s, %s)',
$this->arg1->dispatch($s),
$this->arg2->dispatch($s)
);
case 'sqlite':
return sprintf(
'GreatCircleLength(MakeLine(%s, %s))',
$this->arg1->dispatch($s),
$this->arg2->dispatch($s)
);
}
return sprintf(
self::FORMULA,
self::EARTH_RADIUS,
$this->y($this->arg1->dispatch($s)),
$this->y($this->arg2->dispatch($s)),
$this->y($this->arg1->dispatch($s)),
$this->y($this->arg2->dispatch($s)),
$this->x($this->arg2->dispatch($s)),
$this->x($this->arg1->dispatch($s))
);
} | [
"public",
"function",
"getSql",
"(",
"SqlWalker",
"$",
"s",
")",
"{",
"$",
"platform",
"=",
"$",
"s",
"->",
"getConnection",
"(",
")",
"->",
"getDatabasePlatform",
"(",
")",
"->",
"getName",
"(",
")",
";",
"switch",
"(",
"$",
"platform",
")",
"{",
"c... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Doctrine/Functions/EarthDistanceFunction.php#L59-L89 |
brick/geo | src/Doctrine/Functions/EarthDistanceFunction.php | EarthDistanceFunction.parse | public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->arg1 = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->arg2 = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
} | php | public function parse(Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->arg1 = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
$this->arg2 = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
} | [
"public",
"function",
"parse",
"(",
"Parser",
"$",
"parser",
")",
"{",
"$",
"parser",
"->",
"match",
"(",
"Lexer",
"::",
"T_IDENTIFIER",
")",
";",
"$",
"parser",
"->",
"match",
"(",
"Lexer",
"::",
"T_OPEN_PARENTHESIS",
")",
";",
"$",
"this",
"->",
"arg... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Doctrine/Functions/EarthDistanceFunction.php#L94-L104 |
brick/geo | src/PolyhedralSurface.php | PolyhedralSurface.of | public static function of(Polygon $patch1, Polygon ...$patchN) : PolyhedralSurface
{
return new static($patch1->coordinateSystem(), $patch1, ...$patchN);
} | php | public static function of(Polygon $patch1, Polygon ...$patchN) : PolyhedralSurface
{
return new static($patch1->coordinateSystem(), $patch1, ...$patchN);
} | [
"public",
"static",
"function",
"of",
"(",
"Polygon",
"$",
"patch1",
",",
"Polygon",
"...",
"$",
"patchN",
")",
":",
"PolyhedralSurface",
"{",
"return",
"new",
"static",
"(",
"$",
"patch1",
"->",
"coordinateSystem",
"(",
")",
",",
"$",
"patch1",
",",
"..... | Creates a non-empty PolyhedralSurface composed of the given patches.
@param Polygon $patch1 The first patch.
@param Polygon ...$patchN The subsequent patches, if any.
@return PolyhedralSurface
@throws CoordinateSystemException If the patches use different coordinate systems. | [
"Creates",
"a",
"non",
"-",
"empty",
"PolyhedralSurface",
"composed",
"of",
"the",
"given",
"patches",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/PolyhedralSurface.php#L76-L79 |
brick/geo | src/PolyhedralSurface.php | PolyhedralSurface.patchN | public function patchN(int $n) : Polygon
{
if (! isset($this->patches[$n - 1])) {
throw new NoSuchGeometryException('There is no patch in this PolyhedralSurface at index ' . $n);
}
return $this->patches[$n - 1];
} | php | public function patchN(int $n) : Polygon
{
if (! isset($this->patches[$n - 1])) {
throw new NoSuchGeometryException('There is no patch in this PolyhedralSurface at index ' . $n);
}
return $this->patches[$n - 1];
} | [
"public",
"function",
"patchN",
"(",
"int",
"$",
"n",
")",
":",
"Polygon",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"patches",
"[",
"$",
"n",
"-",
"1",
"]",
")",
")",
"{",
"throw",
"new",
"NoSuchGeometryException",
"(",
"'There is no pat... | Returns the specified patch N in this PolyhedralSurface.
@param int $n The patch number, 1-based.
@return Polygon
@throws NoSuchGeometryException If there is no patch at this index. | [
"Returns",
"the",
"specified",
"patch",
"N",
"in",
"this",
"PolyhedralSurface",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/PolyhedralSurface.php#L98-L105 |
brick/geo | src/PolyhedralSurface.php | PolyhedralSurface.toArray | public function toArray() : array
{
$result = [];
foreach ($this->patches as $patch) {
$result[] = $patch->toArray();
}
return $result;
} | php | public function toArray() : array
{
$result = [];
foreach ($this->patches as $patch) {
$result[] = $patch->toArray();
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"patches",
"as",
"$",
"patch",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"patch",
"->",
"toArray",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/PolyhedralSurface.php#L168-L177 |
brick/geo | src/IO/WKBBuffer.php | WKBBuffer.read | private function read(int $words, int $wordLength) : string
{
$length = $words * $wordLength;
if ($this->position + $length > $this->length) {
throw GeometryIOException::invalidWKB('unexpected end of stream');
}
if ($length === 1) {
return $this->wkb[$this->position++];
}
if ($this->invert) {
$data = '';
for ($i = 0; $i < $words; $i++) {
$data .= strrev(substr($this->wkb, $this->position + $i * $wordLength, $wordLength));
}
} else {
$data = substr($this->wkb, $this->position, $length);
}
$this->position += $length;
return $data;
} | php | private function read(int $words, int $wordLength) : string
{
$length = $words * $wordLength;
if ($this->position + $length > $this->length) {
throw GeometryIOException::invalidWKB('unexpected end of stream');
}
if ($length === 1) {
return $this->wkb[$this->position++];
}
if ($this->invert) {
$data = '';
for ($i = 0; $i < $words; $i++) {
$data .= strrev(substr($this->wkb, $this->position + $i * $wordLength, $wordLength));
}
} else {
$data = substr($this->wkb, $this->position, $length);
}
$this->position += $length;
return $data;
} | [
"private",
"function",
"read",
"(",
"int",
"$",
"words",
",",
"int",
"$",
"wordLength",
")",
":",
"string",
"{",
"$",
"length",
"=",
"$",
"words",
"*",
"$",
"wordLength",
";",
"if",
"(",
"$",
"this",
"->",
"position",
"+",
"$",
"length",
">",
"$",
... | Reads words from the buffer.
@param int $words The number of words to read.
@param int $wordLength The word length in bytes.
@return string
@throws GeometryIOException | [
"Reads",
"words",
"from",
"the",
"buffer",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBBuffer.php#L61-L86 |
brick/geo | src/IO/WKBBuffer.php | WKBBuffer.readByteOrder | public function readByteOrder() : void
{
$byteOrder = $this->readUnsignedChar();
if ($byteOrder !== WKBTools::BIG_ENDIAN && $byteOrder !== WKBTools::LITTLE_ENDIAN) {
throw GeometryIOException::invalidWKB('unknown byte order: ' . $byteOrder);
}
$this->invert = ($byteOrder !== $this->machineByteOrder);
} | php | public function readByteOrder() : void
{
$byteOrder = $this->readUnsignedChar();
if ($byteOrder !== WKBTools::BIG_ENDIAN && $byteOrder !== WKBTools::LITTLE_ENDIAN) {
throw GeometryIOException::invalidWKB('unknown byte order: ' . $byteOrder);
}
$this->invert = ($byteOrder !== $this->machineByteOrder);
} | [
"public",
"function",
"readByteOrder",
"(",
")",
":",
"void",
"{",
"$",
"byteOrder",
"=",
"$",
"this",
"->",
"readUnsignedChar",
"(",
")",
";",
"if",
"(",
"$",
"byteOrder",
"!==",
"WKBTools",
"::",
"BIG_ENDIAN",
"&&",
"$",
"byteOrder",
"!==",
"WKBTools",
... | Reads the machine byte order from the buffer and stores the result to act accordingly.
@return void
@throws GeometryIOException | [
"Reads",
"the",
"machine",
"byte",
"order",
"from",
"the",
"buffer",
"and",
"stores",
"the",
"result",
"to",
"act",
"accordingly",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBBuffer.php#L127-L136 |
brick/geo | src/IO/WKBReader.php | WKBReader.read | public function read(string $wkb, $srid = 0) : Geometry
{
$buffer = new WKBBuffer($wkb);
$geometry = $this->readGeometry($buffer, $srid);
if (! $buffer->isEndOfStream()) {
throw GeometryIOException::invalidWKB('unexpected data at end of stream');
}
return $geometry;
} | php | public function read(string $wkb, $srid = 0) : Geometry
{
$buffer = new WKBBuffer($wkb);
$geometry = $this->readGeometry($buffer, $srid);
if (! $buffer->isEndOfStream()) {
throw GeometryIOException::invalidWKB('unexpected data at end of stream');
}
return $geometry;
} | [
"public",
"function",
"read",
"(",
"string",
"$",
"wkb",
",",
"$",
"srid",
"=",
"0",
")",
":",
"Geometry",
"{",
"$",
"buffer",
"=",
"new",
"WKBBuffer",
"(",
"$",
"wkb",
")",
";",
"$",
"geometry",
"=",
"$",
"this",
"->",
"readGeometry",
"(",
"$",
... | @param string $wkb The WKB to read.
@param int $srid The optional SRID of the geometry.
@return Geometry
@throws GeometryIOException | [
"@param",
"string",
"$wkb",
"The",
"WKB",
"to",
"read",
".",
"@param",
"int",
"$srid",
"The",
"optional",
"SRID",
"of",
"the",
"geometry",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBReader.php#L23-L33 |
brick/geo | src/IO/WKBReader.php | WKBReader.readGeometryHeader | protected function readGeometryHeader(WKBBuffer $buffer, & $geometryType, & $hasZ, & $hasM, & $srid) : void
{
$wkbType = $buffer->readUnsignedLong();
if ($wkbType < 0 || $wkbType >= 4000) {
throw GeometryIOException::unsupportedWKBType($wkbType);
}
$geometryType = $wkbType % 1000;
$dimension = ($wkbType - $geometryType) / 1000;
$hasZ = ($dimension === 1 || $dimension === 3);
$hasM = ($dimension === 2 || $dimension === 3);
} | php | protected function readGeometryHeader(WKBBuffer $buffer, & $geometryType, & $hasZ, & $hasM, & $srid) : void
{
$wkbType = $buffer->readUnsignedLong();
if ($wkbType < 0 || $wkbType >= 4000) {
throw GeometryIOException::unsupportedWKBType($wkbType);
}
$geometryType = $wkbType % 1000;
$dimension = ($wkbType - $geometryType) / 1000;
$hasZ = ($dimension === 1 || $dimension === 3);
$hasM = ($dimension === 2 || $dimension === 3);
} | [
"protected",
"function",
"readGeometryHeader",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"&",
"$",
"geometryType",
",",
"&",
"$",
"hasZ",
",",
"&",
"$",
"hasM",
",",
"&",
"$",
"srid",
")",
":",
"void",
"{",
"$",
"wkbType",
"=",
"$",
"buffer",
"->",
"read... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBReader.php#L38-L51 |
brick/geo | src/IO/GeoJSONWriter.php | GeoJSONWriter.write | public function write(Geometry $geometry) : string
{
if ($geometry instanceof GeometryCollection
// Filter out MultiPoint, MultiLineString and MultiPolygon
&& $geometry->geometryType() === 'GeometryCollection') {
return $this->writeFeatureCollection($geometry);
}
return $this->genGeoJSONString($this->formatGeoJSONGeometry($geometry));
} | php | public function write(Geometry $geometry) : string
{
if ($geometry instanceof GeometryCollection
// Filter out MultiPoint, MultiLineString and MultiPolygon
&& $geometry->geometryType() === 'GeometryCollection') {
return $this->writeFeatureCollection($geometry);
}
return $this->genGeoJSONString($this->formatGeoJSONGeometry($geometry));
} | [
"public",
"function",
"write",
"(",
"Geometry",
"$",
"geometry",
")",
":",
"string",
"{",
"if",
"(",
"$",
"geometry",
"instanceof",
"GeometryCollection",
"// Filter out MultiPoint, MultiLineString and MultiPolygon",
"&&",
"$",
"geometry",
"->",
"geometryType",
"(",
")... | @param Geometry $geometry The geometry to export as GeoJSON.
@return string The GeoJSON representation of the given geometry.
@throws GeometryIOException If the given geometry cannot be exported as GeoJSON. | [
"@param",
"Geometry",
"$geometry",
"The",
"geometry",
"to",
"export",
"as",
"GeoJSON",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/GeoJSONWriter.php#L38-L47 |
brick/geo | src/IO/GeoJSONWriter.php | GeoJSONWriter.formatGeoJSONGeometry | private function formatGeoJSONGeometry(Geometry $geometry) : array
{
$geometryType = $geometry->geometryType();
$validGeometries = [
'Point',
'MultiPoint',
'LineString',
'MultiLineString',
'Polygon',
'MultiPolygon'
];
if (! in_array($geometryType, $validGeometries)) {
throw GeometryIOException::unsupportedGeometryType($geometry->geometryType());
}
return [
'type' => $geometryType,
'coordinates' => $geometry->toArray()
];
} | php | private function formatGeoJSONGeometry(Geometry $geometry) : array
{
$geometryType = $geometry->geometryType();
$validGeometries = [
'Point',
'MultiPoint',
'LineString',
'MultiLineString',
'Polygon',
'MultiPolygon'
];
if (! in_array($geometryType, $validGeometries)) {
throw GeometryIOException::unsupportedGeometryType($geometry->geometryType());
}
return [
'type' => $geometryType,
'coordinates' => $geometry->toArray()
];
} | [
"private",
"function",
"formatGeoJSONGeometry",
"(",
"Geometry",
"$",
"geometry",
")",
":",
"array",
"{",
"$",
"geometryType",
"=",
"$",
"geometry",
"->",
"geometryType",
"(",
")",
";",
"$",
"validGeometries",
"=",
"[",
"'Point'",
",",
"'MultiPoint'",
",",
"... | @param Geometry $geometry
@return array
@throws GeometryIOException | [
"@param",
"Geometry",
"$geometry"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/GeoJSONWriter.php#L56-L76 |
brick/geo | src/IO/GeoJSONWriter.php | GeoJSONWriter.writeFeatureCollection | private function writeFeatureCollection(GeometryCollection $geometryCollection) : string
{
$geojsonArray = [
'type' => 'FeatureCollection',
'features' => []
];
foreach ($geometryCollection->geometries() as $geometry) {
$geojsonArray['features'][] = [
'type' => 'Feature',
'geometry' => $this->formatGeoJSONGeometry($geometry)
];
}
return $this->genGeoJSONString($geojsonArray);
} | php | private function writeFeatureCollection(GeometryCollection $geometryCollection) : string
{
$geojsonArray = [
'type' => 'FeatureCollection',
'features' => []
];
foreach ($geometryCollection->geometries() as $geometry) {
$geojsonArray['features'][] = [
'type' => 'Feature',
'geometry' => $this->formatGeoJSONGeometry($geometry)
];
}
return $this->genGeoJSONString($geojsonArray);
} | [
"private",
"function",
"writeFeatureCollection",
"(",
"GeometryCollection",
"$",
"geometryCollection",
")",
":",
"string",
"{",
"$",
"geojsonArray",
"=",
"[",
"'type'",
"=>",
"'FeatureCollection'",
",",
"'features'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"$"... | @param GeometryCollection $geometryCollection
@return string
@throws GeometryIOException | [
"@param",
"GeometryCollection",
"$geometryCollection"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/GeoJSONWriter.php#L85-L100 |
brick/geo | src/IO/EWKBWriter.php | EWKBWriter.packHeader | protected function packHeader(Geometry $geometry, bool $outer) : string
{
$geometryType = $geometry->geometryTypeBinary();
$cs = $geometry->coordinateSystem();
if ($cs->hasZ()) {
$geometryType |= EWKBTools::Z;
}
if ($cs->hasM()) {
$geometryType |= EWKBTools::M;
}
$srid = $cs->SRID();
if ($srid !== 0 && $outer) {
$geometryType |= EWKBTools::S;
}
$header = $this->packUnsignedInteger($geometryType);
if ($srid !== 0 && $outer) {
$header .= $this->packUnsignedInteger($srid);
}
return $header;
} | php | protected function packHeader(Geometry $geometry, bool $outer) : string
{
$geometryType = $geometry->geometryTypeBinary();
$cs = $geometry->coordinateSystem();
if ($cs->hasZ()) {
$geometryType |= EWKBTools::Z;
}
if ($cs->hasM()) {
$geometryType |= EWKBTools::M;
}
$srid = $cs->SRID();
if ($srid !== 0 && $outer) {
$geometryType |= EWKBTools::S;
}
$header = $this->packUnsignedInteger($geometryType);
if ($srid !== 0 && $outer) {
$header .= $this->packUnsignedInteger($srid);
}
return $header;
} | [
"protected",
"function",
"packHeader",
"(",
"Geometry",
"$",
"geometry",
",",
"bool",
"$",
"outer",
")",
":",
"string",
"{",
"$",
"geometryType",
"=",
"$",
"geometry",
"->",
"geometryTypeBinary",
"(",
")",
";",
"$",
"cs",
"=",
"$",
"geometry",
"->",
"coo... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/EWKBWriter.php#L17-L44 |
brick/geo | proxy-template.php | _CLASSNAME_Proxy.load | private function load() : void
{
$this->proxyGeometry = $this->proxyIsBinary
? _FQCN_::fromBinary($this->proxyData, $this->proxySRID)
: _FQCN_::fromText($this->proxyData, $this->proxySRID);
} | php | private function load() : void
{
$this->proxyGeometry = $this->proxyIsBinary
? _FQCN_::fromBinary($this->proxyData, $this->proxySRID)
: _FQCN_::fromText($this->proxyData, $this->proxySRID);
} | [
"private",
"function",
"load",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"proxyGeometry",
"=",
"$",
"this",
"->",
"proxyIsBinary",
"?",
"_FQCN_",
"::",
"fromBinary",
"(",
"$",
"this",
"->",
"proxyData",
",",
"$",
"this",
"->",
"proxySRID",
")",
":... | Loads the underlying geometry.
@return void
@throws GeometryIOException If the proxy data is not valid.
@throws CoordinateSystemException If the resulting geometry contains mixed coordinate systems.
@throws InvalidGeometryException If the resulting geometry is not valid.
@throws UnexpectedGeometryException If the resulting geometry is not an instance of the proxied class. | [
"Loads",
"the",
"underlying",
"geometry",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/proxy-template.php#L70-L75 |
brick/geo | src/Proxy/CurvePolygonProxy.php | CurvePolygonProxy.exteriorRing | public function exteriorRing() : \Brick\Geo\Curve
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->exteriorRing();
} | php | public function exteriorRing() : \Brick\Geo\Curve
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->exteriorRing();
} | [
"public",
"function",
"exteriorRing",
"(",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Curve",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CurvePolygonProxy.php#L157-L164 |
brick/geo | src/Proxy/CurvePolygonProxy.php | CurvePolygonProxy.numInteriorRings | public function numInteriorRings() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->numInteriorRings();
} | php | public function numInteriorRings() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->numInteriorRings();
} | [
"public",
"function",
"numInteriorRings",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"numInterior... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CurvePolygonProxy.php#L169-L176 |
brick/geo | src/Proxy/CurvePolygonProxy.php | CurvePolygonProxy.interiorRingN | public function interiorRingN(int $n) : \Brick\Geo\Curve
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->interiorRingN($n);
} | php | public function interiorRingN(int $n) : \Brick\Geo\Curve
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->interiorRingN($n);
} | [
"public",
"function",
"interiorRingN",
"(",
"int",
"$",
"n",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Curve",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CurvePolygonProxy.php#L181-L188 |
brick/geo | src/IO/WKBTools.php | WKBTools.checkByteOrder | public static function checkByteOrder(int $byteOrder) : void
{
if ($byteOrder !== self::BIG_ENDIAN && $byteOrder !== self::LITTLE_ENDIAN) {
throw new \InvalidArgumentException('Invalid byte order: ' . var_export($byteOrder, true));
}
} | php | public static function checkByteOrder(int $byteOrder) : void
{
if ($byteOrder !== self::BIG_ENDIAN && $byteOrder !== self::LITTLE_ENDIAN) {
throw new \InvalidArgumentException('Invalid byte order: ' . var_export($byteOrder, true));
}
} | [
"public",
"static",
"function",
"checkByteOrder",
"(",
"int",
"$",
"byteOrder",
")",
":",
"void",
"{",
"if",
"(",
"$",
"byteOrder",
"!==",
"self",
"::",
"BIG_ENDIAN",
"&&",
"$",
"byteOrder",
"!==",
"self",
"::",
"LITTLE_ENDIAN",
")",
"{",
"throw",
"new",
... | @param int $byteOrder
@return void
@throws \InvalidArgumentException | [
"@param",
"int",
"$byteOrder"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBTools.php#L36-L41 |
brick/geo | src/IO/WKBTools.php | WKBTools.getMachineByteOrder | public static function getMachineByteOrder() : int
{
static $byteOrder;
if ($byteOrder === null) {
self::checkDoubleIs64Bit();
switch (pack('L', 0x61626364)) {
case 'abcd':
$byteOrder = self::BIG_ENDIAN;
break;
case 'dcba':
$byteOrder = self::LITTLE_ENDIAN;
break;
default:
throw GeometryIOException::unsupportedEndianness();
}
}
return $byteOrder;
} | php | public static function getMachineByteOrder() : int
{
static $byteOrder;
if ($byteOrder === null) {
self::checkDoubleIs64Bit();
switch (pack('L', 0x61626364)) {
case 'abcd':
$byteOrder = self::BIG_ENDIAN;
break;
case 'dcba':
$byteOrder = self::LITTLE_ENDIAN;
break;
default:
throw GeometryIOException::unsupportedEndianness();
}
}
return $byteOrder;
} | [
"public",
"static",
"function",
"getMachineByteOrder",
"(",
")",
":",
"int",
"{",
"static",
"$",
"byteOrder",
";",
"if",
"(",
"$",
"byteOrder",
"===",
"null",
")",
"{",
"self",
"::",
"checkDoubleIs64Bit",
"(",
")",
";",
"switch",
"(",
"pack",
"(",
"'L'",... | Detects the machine byte order (big endian or little endian).
@return int
@throws GeometryIOException | [
"Detects",
"the",
"machine",
"byte",
"order",
"(",
"big",
"endian",
"or",
"little",
"endian",
")",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKBTools.php#L50-L72 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readGeometry | protected function readGeometry(WKBBuffer $buffer, int $srid) : Geometry
{
$buffer->readByteOrder();
$this->readGeometryHeader($buffer, $geometryType, $hasZ, $hasM, $srid);
$cs = new CoordinateSystem($hasZ, $hasM, $srid);
switch ($geometryType) {
case Geometry::POINT:
return $this->readPoint($buffer, $cs);
case Geometry::LINESTRING:
return $this->readLineString($buffer, $cs);
case Geometry::CIRCULARSTRING:
return $this->readCircularString($buffer, $cs);
case Geometry::COMPOUNDCURVE:
return $this->readCompoundCurve($buffer, $cs);
case Geometry::POLYGON:
return $this->readPolygon($buffer, $cs);
case Geometry::CURVEPOLYGON:
return $this->readCurvePolygon($buffer, $cs);
case Geometry::MULTIPOINT:
return $this->readMultiPoint($buffer, $cs);
case Geometry::MULTILINESTRING:
return $this->readMultiLineString($buffer, $cs);
case Geometry::MULTIPOLYGON:
return $this->readMultiPolygon($buffer, $cs);
case Geometry::GEOMETRYCOLLECTION:
return $this->readGeometryCollection($buffer, $cs);
case Geometry::POLYHEDRALSURFACE:
return $this->readPolyhedralSurface($buffer, $cs);
case Geometry::TIN:
return $this->readTIN($buffer, $cs);
case Geometry::TRIANGLE:
return $this->readTriangle($buffer, $cs);
}
throw GeometryIOException::unsupportedWKBType($geometryType);
} | php | protected function readGeometry(WKBBuffer $buffer, int $srid) : Geometry
{
$buffer->readByteOrder();
$this->readGeometryHeader($buffer, $geometryType, $hasZ, $hasM, $srid);
$cs = new CoordinateSystem($hasZ, $hasM, $srid);
switch ($geometryType) {
case Geometry::POINT:
return $this->readPoint($buffer, $cs);
case Geometry::LINESTRING:
return $this->readLineString($buffer, $cs);
case Geometry::CIRCULARSTRING:
return $this->readCircularString($buffer, $cs);
case Geometry::COMPOUNDCURVE:
return $this->readCompoundCurve($buffer, $cs);
case Geometry::POLYGON:
return $this->readPolygon($buffer, $cs);
case Geometry::CURVEPOLYGON:
return $this->readCurvePolygon($buffer, $cs);
case Geometry::MULTIPOINT:
return $this->readMultiPoint($buffer, $cs);
case Geometry::MULTILINESTRING:
return $this->readMultiLineString($buffer, $cs);
case Geometry::MULTIPOLYGON:
return $this->readMultiPolygon($buffer, $cs);
case Geometry::GEOMETRYCOLLECTION:
return $this->readGeometryCollection($buffer, $cs);
case Geometry::POLYHEDRALSURFACE:
return $this->readPolyhedralSurface($buffer, $cs);
case Geometry::TIN:
return $this->readTIN($buffer, $cs);
case Geometry::TRIANGLE:
return $this->readTriangle($buffer, $cs);
}
throw GeometryIOException::unsupportedWKBType($geometryType);
} | [
"protected",
"function",
"readGeometry",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"int",
"$",
"srid",
")",
":",
"Geometry",
"{",
"$",
"buffer",
"->",
"readByteOrder",
"(",
")",
";",
"$",
"this",
"->",
"readGeometryHeader",
"(",
"$",
"buffer",
",",
"$",
"geo... | @param WKBBuffer $buffer
@param int $srid
@return Geometry
@throws GeometryIOException | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"int",
"$srid"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L51-L101 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readPoint | private function readPoint(WKBBuffer $buffer, CoordinateSystem $cs) : Point
{
$coords = $buffer->readDoubles($cs->coordinateDimension());
return new Point($cs, ...$coords);
} | php | private function readPoint(WKBBuffer $buffer, CoordinateSystem $cs) : Point
{
$coords = $buffer->readDoubles($cs->coordinateDimension());
return new Point($cs, ...$coords);
} | [
"private",
"function",
"readPoint",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"Point",
"{",
"$",
"coords",
"=",
"$",
"buffer",
"->",
"readDoubles",
"(",
"$",
"cs",
"->",
"coordinateDimension",
"(",
")",
")",
";",
"ret... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return Point | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L109-L114 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readLineString | private function readLineString(WKBBuffer $buffer, CoordinateSystem $cs) : LineString
{
$numPoints = $buffer->readUnsignedLong();
$points = [];
for ($i = 0; $i < $numPoints; $i++) {
$points[] = $this->readPoint($buffer, $cs);
}
return new LineString($cs, ...$points);
} | php | private function readLineString(WKBBuffer $buffer, CoordinateSystem $cs) : LineString
{
$numPoints = $buffer->readUnsignedLong();
$points = [];
for ($i = 0; $i < $numPoints; $i++) {
$points[] = $this->readPoint($buffer, $cs);
}
return new LineString($cs, ...$points);
} | [
"private",
"function",
"readLineString",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"LineString",
"{",
"$",
"numPoints",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"points",
"=",
"[",
"]",
";",
"... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return LineString | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L122-L133 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readCircularString | private function readCircularString(WKBBuffer $buffer, CoordinateSystem $cs) : CircularString
{
$numPoints = $buffer->readUnsignedLong();
$points = [];
for ($i = 0; $i < $numPoints; $i++) {
$points[] = $this->readPoint($buffer, $cs);
}
return new CircularString($cs, ...$points);
} | php | private function readCircularString(WKBBuffer $buffer, CoordinateSystem $cs) : CircularString
{
$numPoints = $buffer->readUnsignedLong();
$points = [];
for ($i = 0; $i < $numPoints; $i++) {
$points[] = $this->readPoint($buffer, $cs);
}
return new CircularString($cs, ...$points);
} | [
"private",
"function",
"readCircularString",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"CircularString",
"{",
"$",
"numPoints",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"points",
"=",
"[",
"]",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return CircularString | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L141-L152 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readCompoundCurve | private function readCompoundCurve(WKBBuffer $buffer, CoordinateSystem $cs) : CompoundCurve
{
$numCurves = $buffer->readUnsignedLong();
$curves = [];
for ($i = 0; $i < $numCurves; $i++) {
$curves[] = $this->readGeometry($buffer, $cs->SRID());
}
return new CompoundCurve($cs, ...$curves);
} | php | private function readCompoundCurve(WKBBuffer $buffer, CoordinateSystem $cs) : CompoundCurve
{
$numCurves = $buffer->readUnsignedLong();
$curves = [];
for ($i = 0; $i < $numCurves; $i++) {
$curves[] = $this->readGeometry($buffer, $cs->SRID());
}
return new CompoundCurve($cs, ...$curves);
} | [
"private",
"function",
"readCompoundCurve",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"CompoundCurve",
"{",
"$",
"numCurves",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"curves",
"=",
"[",
"]",
";... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return CompoundCurve | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L160-L170 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readPolygon | private function readPolygon(WKBBuffer $buffer, CoordinateSystem $cs) : Polygon
{
$numRings = $buffer->readUnsignedLong();
$rings = [];
for ($i = 0; $i < $numRings; $i++) {
$rings[] = $this->readLineString($buffer, $cs);
}
return new Polygon($cs, ...$rings);
} | php | private function readPolygon(WKBBuffer $buffer, CoordinateSystem $cs) : Polygon
{
$numRings = $buffer->readUnsignedLong();
$rings = [];
for ($i = 0; $i < $numRings; $i++) {
$rings[] = $this->readLineString($buffer, $cs);
}
return new Polygon($cs, ...$rings);
} | [
"private",
"function",
"readPolygon",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"Polygon",
"{",
"$",
"numRings",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"rings",
"=",
"[",
"]",
";",
"for",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return Polygon | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L178-L189 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readCurvePolygon | private function readCurvePolygon(WKBBuffer $buffer, CoordinateSystem $cs) : CurvePolygon
{
$numRings = $buffer->readUnsignedLong();
$rings = [];
for ($i = 0; $i < $numRings; $i++) {
$rings[] = $this->readGeometry($buffer, $cs->SRID());
}
return new CurvePolygon($cs, ...$rings);
} | php | private function readCurvePolygon(WKBBuffer $buffer, CoordinateSystem $cs) : CurvePolygon
{
$numRings = $buffer->readUnsignedLong();
$rings = [];
for ($i = 0; $i < $numRings; $i++) {
$rings[] = $this->readGeometry($buffer, $cs->SRID());
}
return new CurvePolygon($cs, ...$rings);
} | [
"private",
"function",
"readCurvePolygon",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"CurvePolygon",
"{",
"$",
"numRings",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"rings",
"=",
"[",
"]",
";",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return CurvePolygon | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L197-L208 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readMultiPoint | private function readMultiPoint(WKBBuffer $buffer, CoordinateSystem $cs) : MultiPoint
{
$numPoints = $buffer->readUnsignedLong();
$points = [];
for ($i = 0; $i < $numPoints; $i++) {
$points[] = $this->readGeometry($buffer, $cs->SRID());
}
return new MultiPoint($cs, ...$points);
} | php | private function readMultiPoint(WKBBuffer $buffer, CoordinateSystem $cs) : MultiPoint
{
$numPoints = $buffer->readUnsignedLong();
$points = [];
for ($i = 0; $i < $numPoints; $i++) {
$points[] = $this->readGeometry($buffer, $cs->SRID());
}
return new MultiPoint($cs, ...$points);
} | [
"private",
"function",
"readMultiPoint",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"MultiPoint",
"{",
"$",
"numPoints",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"points",
"=",
"[",
"]",
";",
"... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return MultiPoint | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L216-L226 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readMultiLineString | private function readMultiLineString(WKBBuffer $buffer, CoordinateSystem $cs) : MultiLineString
{
$numLineStrings = $buffer->readUnsignedLong();
$lineStrings = [];
for ($i = 0; $i < $numLineStrings; $i++) {
$lineStrings[] = $this->readGeometry($buffer, $cs->SRID());
}
return new MultiLineString($cs, ...$lineStrings);
} | php | private function readMultiLineString(WKBBuffer $buffer, CoordinateSystem $cs) : MultiLineString
{
$numLineStrings = $buffer->readUnsignedLong();
$lineStrings = [];
for ($i = 0; $i < $numLineStrings; $i++) {
$lineStrings[] = $this->readGeometry($buffer, $cs->SRID());
}
return new MultiLineString($cs, ...$lineStrings);
} | [
"private",
"function",
"readMultiLineString",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"MultiLineString",
"{",
"$",
"numLineStrings",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"lineStrings",
"=",
"[... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return MultiLineString | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L234-L244 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readMultiPolygon | private function readMultiPolygon(WKBBuffer $buffer, CoordinateSystem $cs) : MultiPolygon
{
$numPolygons = $buffer->readUnsignedLong();
$polygons = [];
for ($i = 0; $i < $numPolygons; $i++) {
$polygons[] = $this->readGeometry($buffer, $cs->SRID());
}
return new MultiPolygon($cs, ...$polygons);
} | php | private function readMultiPolygon(WKBBuffer $buffer, CoordinateSystem $cs) : MultiPolygon
{
$numPolygons = $buffer->readUnsignedLong();
$polygons = [];
for ($i = 0; $i < $numPolygons; $i++) {
$polygons[] = $this->readGeometry($buffer, $cs->SRID());
}
return new MultiPolygon($cs, ...$polygons);
} | [
"private",
"function",
"readMultiPolygon",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"MultiPolygon",
"{",
"$",
"numPolygons",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"polygons",
"=",
"[",
"]",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return MultiPolygon | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L252-L262 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readGeometryCollection | private function readGeometryCollection(WKBBuffer $buffer, CoordinateSystem $cs) : GeometryCollection
{
$numGeometries = $buffer->readUnsignedLong();
$geometries = [];
for ($i = 0; $i < $numGeometries; $i++) {
$geometries[] = $this->readGeometry($buffer, $cs->SRID());
}
return new GeometryCollection($cs, ...$geometries);
} | php | private function readGeometryCollection(WKBBuffer $buffer, CoordinateSystem $cs) : GeometryCollection
{
$numGeometries = $buffer->readUnsignedLong();
$geometries = [];
for ($i = 0; $i < $numGeometries; $i++) {
$geometries[] = $this->readGeometry($buffer, $cs->SRID());
}
return new GeometryCollection($cs, ...$geometries);
} | [
"private",
"function",
"readGeometryCollection",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"GeometryCollection",
"{",
"$",
"numGeometries",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"geometries",
"=",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return GeometryCollection | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L270-L280 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readPolyhedralSurface | private function readPolyhedralSurface(WKBBuffer $buffer, CoordinateSystem $cs) : PolyhedralSurface
{
$numPatches = $buffer->readUnsignedLong();
$patches = [];
for ($i = 0; $i < $numPatches; $i++) {
$patches[] = $this->readGeometry($buffer, $cs->SRID());
}
return new PolyhedralSurface($cs, ...$patches);
} | php | private function readPolyhedralSurface(WKBBuffer $buffer, CoordinateSystem $cs) : PolyhedralSurface
{
$numPatches = $buffer->readUnsignedLong();
$patches = [];
for ($i = 0; $i < $numPatches; $i++) {
$patches[] = $this->readGeometry($buffer, $cs->SRID());
}
return new PolyhedralSurface($cs, ...$patches);
} | [
"private",
"function",
"readPolyhedralSurface",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"PolyhedralSurface",
"{",
"$",
"numPatches",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"patches",
"=",
"[",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return PolyhedralSurface | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L288-L298 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readTIN | private function readTIN(WKBBuffer $buffer, CoordinateSystem $cs) : TIN
{
$numPatches = $buffer->readUnsignedLong();
$patches = [];
for ($i = 0; $i < $numPatches; $i++) {
$patches[] = $this->readGeometry($buffer, $cs->SRID());
}
return new TIN($cs, ...$patches);
} | php | private function readTIN(WKBBuffer $buffer, CoordinateSystem $cs) : TIN
{
$numPatches = $buffer->readUnsignedLong();
$patches = [];
for ($i = 0; $i < $numPatches; $i++) {
$patches[] = $this->readGeometry($buffer, $cs->SRID());
}
return new TIN($cs, ...$patches);
} | [
"private",
"function",
"readTIN",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"TIN",
"{",
"$",
"numPatches",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"patches",
"=",
"[",
"]",
";",
"for",
"(",... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return TIN | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L306-L316 |
brick/geo | src/IO/AbstractWKBReader.php | AbstractWKBReader.readTriangle | private function readTriangle(WKBBuffer $buffer, CoordinateSystem $cs) : Triangle
{
$numRings = $buffer->readUnsignedLong();
$rings = [];
for ($i = 0; $i < $numRings; $i++) {
$rings[] = $this->readLineString($buffer, $cs);
}
return new Triangle($cs, ...$rings);
} | php | private function readTriangle(WKBBuffer $buffer, CoordinateSystem $cs) : Triangle
{
$numRings = $buffer->readUnsignedLong();
$rings = [];
for ($i = 0; $i < $numRings; $i++) {
$rings[] = $this->readLineString($buffer, $cs);
}
return new Triangle($cs, ...$rings);
} | [
"private",
"function",
"readTriangle",
"(",
"WKBBuffer",
"$",
"buffer",
",",
"CoordinateSystem",
"$",
"cs",
")",
":",
"Triangle",
"{",
"$",
"numRings",
"=",
"$",
"buffer",
"->",
"readUnsignedLong",
"(",
")",
";",
"$",
"rings",
"=",
"[",
"]",
";",
"for",
... | @param WKBBuffer $buffer
@param CoordinateSystem $cs
@return Triangle | [
"@param",
"WKBBuffer",
"$buffer",
"@param",
"CoordinateSystem",
"$cs"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/AbstractWKBReader.php#L324-L335 |
brick/geo | src/Exception/UnexpectedGeometryException.php | UnexpectedGeometryException.unexpectedGeometryType | public static function unexpectedGeometryType(string $expectedClass, $value) : UnexpectedGeometryException
{
$value = is_object($value) ? get_class($value) : gettype($value);
$message = sprintf('Unexpected geometry type: expected %s, got %s.', $expectedClass, $value);
return new self($message);
} | php | public static function unexpectedGeometryType(string $expectedClass, $value) : UnexpectedGeometryException
{
$value = is_object($value) ? get_class($value) : gettype($value);
$message = sprintf('Unexpected geometry type: expected %s, got %s.', $expectedClass, $value);
return new self($message);
} | [
"public",
"static",
"function",
"unexpectedGeometryType",
"(",
"string",
"$",
"expectedClass",
",",
"$",
"value",
")",
":",
"UnexpectedGeometryException",
"{",
"$",
"value",
"=",
"is_object",
"(",
"$",
"value",
")",
"?",
"get_class",
"(",
"$",
"value",
")",
... | @param string $expectedClass
@param mixed $value
@return UnexpectedGeometryException | [
"@param",
"string",
"$expectedClass",
"@param",
"mixed",
"$value"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Exception/UnexpectedGeometryException.php#L18-L24 |
brick/geo | src/Proxy/CircularStringProxy.php | CircularStringProxy.startPoint | public function startPoint() : \Brick\Geo\Point
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->startPoint();
} | php | public function startPoint() : \Brick\Geo\Point
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->startPoint();
} | [
"public",
"function",
"startPoint",
"(",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Point",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CircularStringProxy.php#L157-L164 |
brick/geo | src/Proxy/CircularStringProxy.php | CircularStringProxy.endPoint | public function endPoint() : \Brick\Geo\Point
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->endPoint();
} | php | public function endPoint() : \Brick\Geo\Point
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->endPoint();
} | [
"public",
"function",
"endPoint",
"(",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Point",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CircularStringProxy.php#L169-L176 |
brick/geo | src/Proxy/CircularStringProxy.php | CircularStringProxy.numPoints | public function numPoints() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->numPoints();
} | php | public function numPoints() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->numPoints();
} | [
"public",
"function",
"numPoints",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"numPoints",
"(",... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CircularStringProxy.php#L181-L188 |
brick/geo | src/Proxy/CircularStringProxy.php | CircularStringProxy.pointN | public function pointN(int $n) : \Brick\Geo\Point
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->pointN($n);
} | php | public function pointN(int $n) : \Brick\Geo\Point
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->pointN($n);
} | [
"public",
"function",
"pointN",
"(",
"int",
"$",
"n",
")",
":",
"\\",
"Brick",
"\\",
"Geo",
"\\",
"Point",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/CircularStringProxy.php#L193-L200 |
brick/geo | src/IO/WKTReader.php | WKTReader.read | public function read(string $wkt, int $srid = 0) : Geometry
{
$parser = new WKTParser(strtoupper($wkt));
$geometry = $this->readGeometry($parser, $srid);
if (! $parser->isEndOfStream()) {
throw GeometryIOException::invalidWKT();
}
return $geometry;
} | php | public function read(string $wkt, int $srid = 0) : Geometry
{
$parser = new WKTParser(strtoupper($wkt));
$geometry = $this->readGeometry($parser, $srid);
if (! $parser->isEndOfStream()) {
throw GeometryIOException::invalidWKT();
}
return $geometry;
} | [
"public",
"function",
"read",
"(",
"string",
"$",
"wkt",
",",
"int",
"$",
"srid",
"=",
"0",
")",
":",
"Geometry",
"{",
"$",
"parser",
"=",
"new",
"WKTParser",
"(",
"strtoupper",
"(",
"$",
"wkt",
")",
")",
";",
"$",
"geometry",
"=",
"$",
"this",
"... | @param string $wkt The WKT to read.
@param int $srid The optional SRID of the geometry.
@return Geometry
@throws GeometryIOException | [
"@param",
"string",
"$wkt",
"The",
"WKT",
"to",
"read",
".",
"@param",
"int",
"$srid",
"The",
"optional",
"SRID",
"of",
"the",
"geometry",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/WKTReader.php#L23-L33 |
brick/geo | src/Doctrine/Types/GeometryType.php | GeometryType.convertToPHPValue | public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
if (is_resource($value)) {
$value = stream_get_contents($value);
}
$proxyClassName = $this->getProxyClassName();
return new $proxyClassName($value, true, self::$srid);
} | php | public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
if (is_resource($value)) {
$value = stream_get_contents($value);
}
$proxyClassName = $this->getProxyClassName();
return new $proxyClassName($value, true, self::$srid);
} | [
"public",
"function",
"convertToPHPValue",
"(",
"$",
"value",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Doctrine/Types/GeometryType.php#L65-L78 |
brick/geo | src/Doctrine/Types/GeometryType.php | GeometryType.convertToDatabaseValue | public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
if ($value instanceof Geometry) {
return $value->asBinary();
}
$type = is_object($value) ? get_class($value) : gettype($value);
throw new \UnexpectedValueException(sprintf('Expected %s, got %s.', Geometry::class, $type));
} | php | public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}
if ($value instanceof Geometry) {
return $value->asBinary();
}
$type = is_object($value) ? get_class($value) : gettype($value);
throw new \UnexpectedValueException(sprintf('Expected %s, got %s.', Geometry::class, $type));
} | [
"public",
"function",
"convertToDatabaseValue",
"(",
"$",
"value",
",",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Geometry",
")",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Doctrine/Types/GeometryType.php#L83-L96 |
brick/geo | src/Proxy/SurfaceProxy.php | SurfaceProxy.geometryType | public function geometryType() : string
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->geometryType();
} | php | public function geometryType() : string
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->geometryType();
} | [
"public",
"function",
"geometryType",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"geometryType... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/SurfaceProxy.php#L181-L188 |
brick/geo | src/Proxy/SurfaceProxy.php | SurfaceProxy.geometryTypeBinary | public function geometryTypeBinary() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->geometryTypeBinary();
} | php | public function geometryTypeBinary() : int
{
if ($this->proxyGeometry === null) {
$this->load();
}
return $this->proxyGeometry->geometryTypeBinary();
} | [
"public",
"function",
"geometryTypeBinary",
"(",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"proxyGeometry",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"proxyGeometry",
"->",
"geometryT... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/Proxy/SurfaceProxy.php#L193-L200 |
brick/geo | src/IO/EWKTWriter.php | EWKTWriter.write | public function write(Geometry $geometry) : string
{
$srid = $geometry->SRID();
if ($srid === 0) {
return $this->doWrite($geometry);
}
return 'SRID=' . $geometry->SRID() . ';' . $this->prettyPrintSpace . $this->doWrite($geometry);
} | php | public function write(Geometry $geometry) : string
{
$srid = $geometry->SRID();
if ($srid === 0) {
return $this->doWrite($geometry);
}
return 'SRID=' . $geometry->SRID() . ';' . $this->prettyPrintSpace . $this->doWrite($geometry);
} | [
"public",
"function",
"write",
"(",
"Geometry",
"$",
"geometry",
")",
":",
"string",
"{",
"$",
"srid",
"=",
"$",
"geometry",
"->",
"SRID",
"(",
")",
";",
"if",
"(",
"$",
"srid",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"doWrite",
"(",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/IO/EWKTWriter.php#L17-L26 |
brick/geo | src/CurvePolygon.php | CurvePolygon.of | public static function of(Curve $exteriorRing, Curve ...$interiorRings) : CurvePolygon
{
return new static($exteriorRing->coordinateSystem(), $exteriorRing, ...$interiorRings);
} | php | public static function of(Curve $exteriorRing, Curve ...$interiorRings) : CurvePolygon
{
return new static($exteriorRing->coordinateSystem(), $exteriorRing, ...$interiorRings);
} | [
"public",
"static",
"function",
"of",
"(",
"Curve",
"$",
"exteriorRing",
",",
"Curve",
"...",
"$",
"interiorRings",
")",
":",
"CurvePolygon",
"{",
"return",
"new",
"static",
"(",
"$",
"exteriorRing",
"->",
"coordinateSystem",
"(",
")",
",",
"$",
"exteriorRin... | Creates a non-empty CurvePolygon composed of the given rings.
@param Curve $exteriorRing The exterior ring.
@param Curve ...$interiorRings The interior rings, if any.
@return CurvePolygon
@throws CoordinateSystemException If the rings use different coordinate systems. | [
"Creates",
"a",
"non",
"-",
"empty",
"CurvePolygon",
"composed",
"of",
"the",
"given",
"rings",
"."
] | train | https://github.com/brick/geo/blob/c846384f4e770d1517c5c202a10657ce8a2cae1a/src/CurvePolygon.php#L64-L67 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.