Skip to content

Commit 68a2819

Browse files
committed
renamed objects to camelCase, Url -> Request, UrlInfo -> Url
1 parent 142fadd commit 68a2819

36 files changed

+901
-895
lines changed

Embed/Adapters/Adapter.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
namespace Embed\Adapters;
88

9-
use Embed\Url;
9+
use Embed\Request;
1010
use Embed\FastImage;
1111

1212
abstract class Adapter
@@ -22,18 +22,18 @@ abstract class Adapter
2222
'embedlyKey' => null
2323
);
2424

25-
abstract protected function initProviders (Url $Url);
25+
abstract protected function initProviders (Request $request);
2626

27-
public function __construct(Url $Url, array $options = null)
27+
public function __construct(Request $request, array $options = null)
2828
{
2929
if ($options !== null) {
3030
$this->options = array_replace($this->options, $options);
3131
}
3232

33-
$this->initProviders($Url);
33+
$this->initProviders($request);
3434

35-
if ($Url->getUrl() !== $this->url) {
36-
$this->initProviders(new Url($this->url));
35+
if ($request->getUrl() !== $this->url) {
36+
$this->initProviders(new Request($this->url));
3737
}
3838
}
3939

@@ -52,8 +52,8 @@ public function getFromProviders($name, $returnFirst = true)
5252
$values = array();
5353
$current = null;
5454

55-
foreach ($this->providers as $Provider) {
56-
if (($value = $Provider->$method())) {
55+
foreach ($this->providers as $provider) {
56+
if (($value = $provider->$method())) {
5757
if ($returnFirst === true) {
5858
return $value;
5959
}
@@ -77,16 +77,16 @@ public function getUrlFromProviders($name)
7777
{
7878
$method = 'get'.$name;
7979

80-
foreach ($this->providers as $Provider) {
81-
if (($url = $Provider->$method())) {
82-
return $this->Url->getAbsolute($url);
80+
foreach ($this->providers as $provider) {
81+
if (($url = $provider->$method())) {
82+
return $this->request->getAbsolute($url);
8383
}
8484
}
8585
}
8686

8787
public function getTitle()
8888
{
89-
return $this->getFromProviders('title') ?: $this->Url->getUrl();
89+
return $this->getFromProviders('title') ?: $this->request->getUrl();
9090
}
9191

9292
public function getDescription()
@@ -96,7 +96,7 @@ public function getDescription()
9696

9797
public function getUrl()
9898
{
99-
return $this->getUrlFromProviders('url') ?: $this->Url->getUrl();
99+
return $this->getUrlFromProviders('url') ?: $this->request->getUrl();
100100
}
101101

102102
public function getSource()
@@ -126,21 +126,21 @@ public function getAspectRatio()
126126

127127
public function getImage()
128128
{
129-
foreach ($this->images as $image) {
129+
foreach ($this->images as $src) {
130130
try {
131-
$Image = new FastImage($image);
132-
} catch (\Exception $Exception) {
131+
$image = new FastImage($src);
132+
} catch (\Exception $exception) {
133133
continue;
134134
}
135135

136-
if ($Image->getType()) {
137-
list($width, $height) = $Image->getSize();
136+
if ($image->getType()) {
137+
list($width, $height) = $image->getSize();
138138

139139
if (($width >= $this->options['minImageWidth']) && ($height >= $this->options['minImageHeight'])) {
140140
$this->imageWidth = $width;
141141
$this->imageHeight = $height;
142142

143-
return $image;
143+
return $src;
144144
}
145145
}
146146
}
@@ -154,27 +154,27 @@ public function getProviderIcon()
154154
return current($icons);
155155
}
156156

157-
foreach ($this->providerIcons as $icon) {
157+
foreach ($this->providerIcons as $src) {
158158
try {
159-
$Icon = new FastImage($icon);
160-
} catch (\Exception $Exception) {
159+
$icon = new FastImage($src);
160+
} catch (\Exception $exception) {
161161
continue;
162162
}
163163

164-
if ($Icon->getType()) {
165-
return $icon;
164+
if ($icon->getType()) {
165+
return $src;
166166
}
167167
}
168168
}
169169

170170
public function getProviderName()
171171
{
172-
return $this->getFromProviders('providerName') ?: $this->Url->getDomain();
172+
return $this->getFromProviders('providerName') ?: $this->request->getDomain();
173173
}
174174

175175
public function getProviderUrl()
176176
{
177-
return $this->getUrlFromProviders('providerUrl') ?: ($this->Url->getScheme().'://'.$this->Url->getDomain(true));
177+
return $this->getUrlFromProviders('providerUrl') ?: ($this->request->getScheme().'://'.$this->request->getDomain(true));
178178
}
179179

180180
public function getImageWidth()

Embed/Adapters/AdapterInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55
namespace Embed\Adapters;
66

7-
use Embed\Url;
7+
use Embed\Request;
88

99
interface AdapterInterface
1010
{
11-
public static function check (Url $Url);
11+
public static function check (Request $request);
1212

13-
public function __construct (Url $Url, array $options = null);
13+
public function __construct (Request $request, array $options = null);
1414

1515
public function getTitle ();
1616

Embed/Adapters/Archive.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@
44
*/
55
namespace Embed\Adapters;
66

7-
use Embed\Url;
7+
use Embed\Request;
88
use Embed\Viewers;
99
use Embed\Providers\Provider;
1010

1111
class Archive extends Webpage implements AdapterInterface
1212
{
13-
public $Api;
13+
public $api;
1414

15-
public static function check(Url $Url)
15+
public static function check(Request $request)
1616
{
17-
return $Url->match(array(
17+
return $request->match(array(
1818
'http://archive.org/details/*'
1919
));
2020
}
2121

22-
protected function initProviders(Url $Url)
22+
protected function initProviders(Request $request)
2323
{
24-
parent::initProviders($Url);
24+
parent::initProviders($request);
2525

26-
$this->Api = new Provider();
26+
$this->api = new Provider();
2727

28-
$UrlApi = clone $Url;
29-
$UrlApi->setParameter('output', 'json');
28+
$api = clone $request;
29+
$api->setParameter('output', 'json');
3030

31-
if (($json = $UrlApi->getJsonContent())) {
32-
$this->Api->set($json);
31+
if (($json = $api->getJsonContent())) {
32+
$this->api->set($json);
3333
}
3434
}
3535

3636
private function getMetadata($key)
3737
{
38-
if (($metadata = $this->Api->get('metadata', $key)) && isset($metadata[0])) {
38+
if (($metadata = $this->api->get('metadata', $key)) && isset($metadata[0])) {
3939
return $metadata[0];
4040
}
4141
}
@@ -95,14 +95,14 @@ public function getImages()
9595
{
9696
$images = array();
9797

98-
if (($image = $this->Api->get('misc', 'image'))) {
99-
$images[] = $this->Url->getAbsolute($image);
98+
if (($image = $this->api->get('misc', 'image'))) {
99+
$images[] = $this->request->getAbsolute($image);
100100
}
101101

102-
if (($files = $this->Api->get('files'))) {
102+
if (($files = $this->api->get('files'))) {
103103
foreach ($files as $url => $info) {
104104
if ($info['format'] === 'Thumbnail') {
105-
$images[] = $this->Url->getAbsolute($url);
105+
$images[] = $this->request->getAbsolute($url);
106106
}
107107
}
108108
}

Embed/Adapters/Cadenaser.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ class Cadenaser extends Webpage implements AdapterInterface
88
{
99
public function getCode()
1010
{
11-
$Dom = $this->Url->getHtmlContent();
11+
$dom = $this->request->getHtmlContent();
1212

13-
foreach ($Dom->getElementsByTagName('div') as $Div) {
14-
if ($Div->hasAttribute('class') && ($Div->getAttribute('class') === 'llevatelo')) {
15-
$Input = $Div->getElementsByTagName('input');
13+
foreach ($dom->getElementsByTagName('div') as $div) {
14+
if ($div->hasAttribute('class') && ($div->getAttribute('class') === 'llevatelo')) {
15+
$input = $div->getElementsByTagName('input');
1616

17-
if ($Input->length && $Input->item(0)->hasAttribute('value')) {
18-
return $Input->item(0)->getAttribute('value');
17+
if ($input->length && $input->item(0)->hasAttribute('value')) {
18+
return $input->item(0)->getAttribute('value');
1919
}
2020
}
2121
}

Embed/Adapters/Codepen.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
namespace Embed\Adapters;
66

77
use Embed\Viewers;
8-
use Embed\Url;
8+
use Embed\Request;
99

1010
class Codepen extends Webpage implements AdapterInterface
1111
{
12-
public static function check(Url $Url)
12+
public static function check(Request $request)
1313
{
14-
return $Url->match(array(
14+
return $request->match(array(
1515
'http://codepen.io/*/pen/*'
1616
));
1717
}

Embed/Adapters/Facebook.php

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,69 @@
55
namespace Embed\Adapters;
66

77
use Embed\Providers\Provider;
8+
use Embed\Request;
89
use Embed\Url;
910

1011
class Facebook extends Webpage implements AdapterInterface
1112
{
12-
public $Api;
13+
public $api;
1314

14-
public static function check(Url $Url)
15+
public static function check(Request $request)
1516
{
16-
return $Url->match(array(
17+
return $request->match(array(
1718
'https://www.facebook.com/*'
1819
));
1920
}
2021

21-
protected function initProviders(Url $Url)
22+
protected function initProviders(Request $request)
2223
{
23-
parent::initProviders($Url);
24+
parent::initProviders($request);
2425

25-
$this->Api = new Provider();
26+
$this->api = new Provider();
2627

2728
if ($this->options['facebookAccessToken']) {
28-
$StartingUrl = new Url($Url->getStartingUrl());
29-
30-
if ($StartingUrl->hasParameter('fbid')) {
31-
$id = $StartingUrl->getParameter('fbid');
32-
} elseif ($StartingUrl->hasParameter('story_fbid')) {
33-
$id = $StartingUrl->getParameter('story_fbid');
34-
} elseif ($StartingUrl->getDirectory(0) === 'events') {
35-
$id = $StartingUrl->getDirectory(1);
36-
} elseif ($StartingUrl->getDirectory(0) === 'pages') {
37-
$id = $StartingUrl->getDirectory(2);
38-
} elseif ($StartingUrl->getDirectory(1) === 'posts') {
39-
$id = $StartingUrl->getDirectory(2);
40-
} elseif ($StartingUrl->getDirectory(2) === 'posts') {
41-
$id = $StartingUrl->getDirectory(3);
29+
$url = new Url($request->getStartingUrl());
30+
31+
if ($url->hasParameter('fbid')) {
32+
$id = $url->getParameter('fbid');
33+
} elseif ($url->hasParameter('story_fbid')) {
34+
$id = $url->getParameter('story_fbid');
35+
} elseif ($url->getDirectory(0) === 'events') {
36+
$id = $url->getDirectory(1);
37+
} elseif ($url->getDirectory(0) === 'pages') {
38+
$id = $url->getDirectory(2);
39+
} elseif ($url->getDirectory(1) === 'posts') {
40+
$id = $url->getDirectory(2);
41+
} elseif ($url->getDirectory(2) === 'posts') {
42+
$id = $url->getDirectory(3);
4243
} else {
43-
$id = $StartingUrl->getDirectory(0);
44+
$id = $url->getDirectory(0);
4445
}
4546

4647
if ($id) {
47-
$UrlApi = new Url('https://graph.facebook.com/'.$id);
48-
$UrlApi->setParameter('access_token', $this->options['facebookAccessToken']);
48+
$api = new Request('https://graph.facebook.com/'.$id);
49+
$api->setParameter('access_token', $this->options['facebookAccessToken']);
4950

50-
if ($json = $UrlApi->getJsonContent()) {
51-
$this->Api->set($json);
51+
if ($json = $api->getJsonContent()) {
52+
$this->api->set($json);
5253
}
5354
}
5455
}
5556
}
5657

5758
public function getTitle()
5859
{
59-
return $this->Api->get('name') ?: parent::getTitle();
60+
return $this->api->get('name') ?: parent::getTitle();
6061
}
6162

6263
public function getDescription()
6364
{
64-
return $this->Api->get('description') ?: $this->Api->get('about') ?: parent::getTitle();
65+
return $this->api->get('description') ?: $this->api->get('about') ?: parent::getTitle();
6566
}
6667

6768
public function getUrl()
6869
{
69-
return $this->Api->get('link') ?: $this->Url->getStartingUrl();
70+
return $this->api->get('link') ?: $this->request->getStartingUrl();
7071
}
7172

7273
public function getProviderName()
@@ -76,12 +77,12 @@ public function getProviderName()
7677

7778
public function getAuthorName()
7879
{
79-
return $this->Api->get('username') ?: parent::getAuthorName();
80+
return $this->api->get('username') ?: parent::getAuthorName();
8081
}
8182

8283
public function getSource()
8384
{
84-
$id = $this->Api->get('id');
85+
$id = $this->api->get('id');
8586

8687
if ($id) {
8788
return 'https://www.facebook.com/feeds/page.php?id='.$id.'&format=rss20';
@@ -92,13 +93,13 @@ public function getImages()
9293
{
9394
$images = parent::getImages();
9495

95-
$cover = $this->Api->get('cover');
96+
$cover = $this->api->get('cover');
9697

9798
if ($cover && !empty($cover['source'])) {
9899
array_unshift($images, $cover['source']);
99100
}
100101

101-
$id = $this->Api->get('id');
102+
$id = $this->api->get('id');
102103

103104
if ($id) {
104105
array_unshift($images, 'https://graph.facebook.com/'.$id.'/picture');

0 commit comments

Comments
 (0)