Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit d473b62

Browse files
committed
🚿
1 parent 9b6e3dd commit d473b62

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

examples/endpoint-map/LastFM.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
$params = [];
3232
# $str = [];
3333

34-
$href = $a->getAttribute('href');
34+
$href = $a->getHref();
3535
$path = str_replace('/api/show/', '' ,$href);
3636

3737
if(in_array($path, ['auth.getMobileSession', 'auth.getSession', 'auth.getToken', 'track.scrobble'])){
@@ -41,17 +41,17 @@
4141
$link = 'https://www.last.fm'.$href;
4242
$page = (new Document(file_get_contents($link)));
4343
$name = lcfirst(implode('', array_map('ucfirst', explode('.', $path))));
44-
$desc = trim($page->select(['.theme-default-content h1'])[0]->next('p')->nodeValue);
44+
$desc = $page->select(['.theme-default-content h1'])[0]->next('p')->value();
4545

46-
foreach($page->select(['.theme-default-content #params'])[0]->next('p')->childNodes as $nodeList){
46+
foreach($page->select(['.theme-default-content #params'])[0]->next('p')->childElements() as $node){
4747

48-
if($nodeList->nodeName === 'strong'){
49-
$param->name = str_replace('[0|1]', '',trim($nodeList->nodeValue));
48+
if($node->tag() === 'strong'){
49+
$param->name = str_replace('[0|1]', '', $node->value());
5050
}
51-
# elseif($nodeList->nodeName === '#text'){
52-
# $str[] = $nodeList->nodeValue;
51+
# elseif($node->name() === '#text'){
52+
# $str[] = $node->value();
5353
# }
54-
elseif($nodeList->nodeName === 'br'){
54+
elseif($node->tag() === 'br'){
5555

5656
if(in_array($param->name, ['api_key', 'api_sig', 'sk'])){
5757
continue;
@@ -65,7 +65,7 @@
6565
}
6666
}
6767

68-
$method = strpos($page->select(['.theme-default-content #auth'])[0]->next('p')->nodeValue, 'HTTP POST') !== false
68+
$method = strpos($page->select(['.theme-default-content #auth'])[0]->next('p')->value(), 'HTTP POST') !== false
6969
? 'POST' : 'GET';
7070

7171
$param_names = array_column($params, 'name');

examples/endpoint-map/Spotify.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444
$nodes = $document->getElementsByClassName('post-content')[0]->childElements();
4545

46-
$endpoints = [];
4746
$endpoint = new stdClass;
47+
$endpoints = [];
4848
$content = [];
4949

5050
foreach($nodes as $node){
@@ -54,32 +54,32 @@
5454
}
5555

5656
if($node->nodeName === 'h2'){
57-
$endpoint->desc = $node->childNodes[0]->nodeValue;
58-
$endpoint->link = $url.'#'.$node->getID();
57+
$endpoint->desc = $node->value();
58+
$endpoint->link = $url.'#'.$node->identify();
5959
}
6060
elseif($node->getClassName() === 'hidden-xs'){
61-
[$endpoint->method, $endpoint->url] = explode(' ', trim($node->down(1)->nodeValue));
61+
[$endpoint->method, $endpoint->url] = explode(' ', $node->down(1)->value());
6262
}
6363
elseif($node->nodeName === 'table'){
6464

6565
$params = $node->down(0)->next()->childElements()->map(function(PrototypeHTMLElement $tr){
66-
$p = new stdClass;
67-
$td = $tr->childElements();
68-
$p->name = str_replace(['{', '}'], '', $td[0]->down()->nodeValue);
66+
$p = new stdClass;
67+
$td = $tr->childElements();
68+
$p->name = str_replace(['{', '}'], '', $td[0]->down()->value());
6969
$p->type = $td[1]->nodeValue;
7070

7171
if(isset($td[0]->childElements()[2])){
72-
$p->desc = $td[0]->childElements()[2]->nodeValue;
72+
$p->desc = $td[0]->childElements()[2]->value();
7373
}
7474

7575
if($td[2] instanceof PrototypeHTMLElement){
76-
$p->required = $td[2]->childElements()[0]->nodeValue === 'Required';
76+
$p->required = $td[2]->childElements()[0]->value() === 'Required';
7777
}
7878

7979
return $p;
8080
});
8181

82-
$type = $node->down(2)->nodeValue;
82+
$type = $node->down(2)->value();
8383

8484
if($type === 'Header'){
8585
$endpoint->headers = $params;

examples/endpoint-map/Twitch.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,31 @@
6060

6161
foreach($headers as $header){
6262

63-
if($header->nodeName === 'h2'){
64-
$endpoint->desc = $header->nodeValue;
65-
$endpoint->link = $url.'#'.$header->getID();
63+
if($header->tag() === 'h2'){
64+
$endpoint->desc = $header->value();
65+
$endpoint->link = $url.'#'.$header->identify();
6666
}
67-
elseif($header->nodeName === 'h3'){
67+
elseif($header->tag() === 'h3'){
6868

69-
if(strpos($header->nodeValue, 'URL') !== false){
70-
$v = explode(' ', $header->next()->nodeValue);
69+
if(strpos($header->value(), 'URL') !== false){
70+
$v = explode(' ', $header->next()->value());
7171
$l = count($v) >= 2;
7272

7373
$endpoint->method = $l ? $v[0] : 'GET';
7474
$endpoint->url = preg_replace('/^\s+|\s+$|[^\S ]/u', '', ($l ? explode('?', $v[1])[0] : $v[0]));
7575

7676
$endpointMethods[str_replace(['https://api.twitch.tv/', 'helix'], '', $endpoint->url)][] = $endpoint->method;
7777
}
78-
elseif(preg_match($headerPattern, $header->nodeValue)){
78+
elseif(preg_match($headerPattern, $header->value())){
7979

8080
$table = $header->next('table');
8181

8282
// no table follows that header - no params
83-
if(!$table || $table->previous('h3')->nodeValue !== $header->nodeValue){
83+
if(!$table || $table->previous('h3')->value() !== $header->value()){
8484
continue;
8585
}
8686

87-
$h = explode(' ', $header->nodeValue);
87+
$h = explode(' ', $header->value());
8888
$type = strtolower(count($h) === 3 ? $h[1] : $h[0]);
8989

9090
if($type === 'return'){
@@ -102,7 +102,7 @@
102102
$keys = $tds->count() === 3 ? ['name', 'type', 'desc'] : ['name', 'required', 'type', 'desc'];
103103

104104
foreach($tds as $i => $td){
105-
$params->{$keys[$i]} = $td->nodeValue;
105+
$params->{$keys[$i]} = $td->value();
106106
}
107107

108108
if($type !== 'response'){

0 commit comments

Comments
 (0)