Skip to content

Commit 2aec187

Browse files
committed
bugfixes
1 parent 0d58921 commit 2aec187

File tree

7 files changed

+31
-57
lines changed

7 files changed

+31
-57
lines changed

src/Adapters/Adapter.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,13 @@
44

55
use Embed\Http\Uri;
66
use Embed\Http\Response;
7+
use Embed\Http\ImageResponse;
78
use Embed\Http\DispatcherInterface;
89
use Embed\Bag;
910
use Embed\Embed;
1011

1112
/**
1213
* Base class extended by all adapters.
13-
*
14-
* @property null|string $title
15-
* @property null|string $description
16-
* @property null|string $url
17-
* @property null|string $type
18-
* @property array $tags
19-
* @property array $feeds
20-
* @property array $images
21-
* @property array $imagesUrls
22-
* @property null|string $image
23-
* @property null|int $imageWidth
24-
* @property null|int $imageHeight
25-
* @property null|string $code
26-
* @property null|int $width
27-
* @property null|int $height
28-
* @property null|float $aspectRatio
29-
* @property null|string $authorName
30-
* @property null|string $authorUrl
31-
* @property array $providerIcons
32-
* @property array $providerIconsUrls
33-
* @property null|string $providerIcon
34-
* @property null|string $providerName
35-
* @property null|string $providerUrl
36-
* @property null|string $publishedTime
3714
*/
3815
abstract class Adapter
3916
{
@@ -575,7 +552,7 @@ private function dispatchImagesInfo($urls)
575552
}
576553

577554
return array_map(
578-
function ($response) {
555+
function (ImageResponse $response) {
579556
return [
580557
'url' => (string) $response->getUri(),
581558
'width' => $response->getWidth(),

src/Adapters/AdapterInterface.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@
99

1010
/**
1111
* Interface used by all adapters.
12+
*
13+
* @property null|string $title
14+
* @property null|string $description
15+
* @property null|string $url
16+
* @property null|string $type
17+
* @property array $tags
18+
* @property array $feeds
19+
* @property array $images
20+
* @property array $imagesUrls
21+
* @property null|string $image
22+
* @property null|int $imageWidth
23+
* @property null|int $imageHeight
24+
* @property null|string $code
25+
* @property null|int $width
26+
* @property null|int $height
27+
* @property null|float $aspectRatio
28+
* @property null|string $authorName
29+
* @property null|string $authorUrl
30+
* @property array $providerIcons
31+
* @property array $providerIconsUrls
32+
* @property null|string $providerIcon
33+
* @property null|string $providerName
34+
* @property null|string $providerUrl
35+
* @property null|string $publishedTime
1236
*/
1337
interface AdapterInterface extends DataInterface
1438
{

src/Http/CurlDispatcher.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Embed\Embed;
66
use Embed\Exceptions\EmbedException;
7+
use stdClass;
78

89
/**
910
* Curl dispatcher.
@@ -146,7 +147,7 @@ public function dispatchImages(array $uris)
146147

147148
$curl = new CurlResult($connection);
148149

149-
$curl->onBody(function ($body, $data) use ($finfo, $mimetypes) {
150+
$curl->onBody(function ($body, stdClass $data) use ($finfo, $mimetypes) {
150151
if (empty($data->mime)) {
151152
$data->mime = finfo_buffer($finfo, $body);
152153

src/Providers/OEmbed/Embedly.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Embed\Adapters\AdapterInterface;
66
use Embed\Http\Response;
7-
use Embed\Url;
7+
use Embed\Http\Uri;
88

99
class Embedly implements EndPointInterface
1010
{

src/Providers/OEmbed/Iframely.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Embed\Adapters\AdapterInterface;
66
use Embed\Http\Response;
7-
use Embed\Url;
7+
use Embed\Http\Uri;
88

99
class Iframely implements EndPointInterface
1010
{

tests/AbstractTestCase.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Embed\Embed;
77
use Embed\Http\Response;
88
use Embed\Adapters\AdapterInterface;
9+
use InvalidArgumentException;
910

1011
/**
1112
* Base class with custom utilities for testing.
@@ -81,30 +82,5 @@ protected function assertEmbed($url, array $info, array $config = array())
8182
throw new InvalidArgumentException("No valid {$name} assertion");
8283
}
8384
}
84-
85-
//$this->assertOembedAutodiscover($i->getResponse());
86-
}
87-
88-
/**
89-
* This method allow to discover sites including the oembed endpoint in the code,
90-
* to remove the custom Oembed provider if exists.
91-
*/
92-
private function assertOembedAutodiscover(Response $response)
93-
{
94-
$className = $response->getUri()->getClassNameForDomain();
95-
96-
//exceptions
97-
if (in_array($className, ['Wordpress', 'Youtube', 'Jsbin'])) {
98-
return;
99-
}
100-
101-
$class = 'Embed\\Providers\\OEmbed\\'.$className;
102-
103-
if (class_exists($class)) {
104-
$body = $response->getContent();
105-
106-
$this->assertFalse(strpos($body, '/json+oembed'), 'Autodiscovered json OEmbed');
107-
$this->assertFalse(strpos($body, '/xml+oembed'), 'Autodiscovered xml OEmbed');
108-
}
10985
}
11086
}

tests/ImageInfoTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ public function testBase64Images()
2929
{
3030
$dispatcher = new CurlDispatcher();
3131

32-
$result = $dispatcher->dispatchImages([
33-
Uri::create('http://www.mixdecultura.ro/wp-content/uploads/2013/03/galicia-locuinte-celtice.jpg'),
34-
]);
35-
3632
$info = Embed::create('http://www.websiteoptimization.com/speed/tweak/inline-images/folder-test.html');
3733

3834
$this->assertEquals(

0 commit comments

Comments
 (0)