Skip to content

Commit a0155f8

Browse files
committed
Added __isset() magic method. Fixes #181
1 parent 324d74d commit a0155f8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Adapters/Adapter.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(Response $response, array $config, DispatcherInterfa
7878
abstract protected function init();
7979

8080
/**
81-
* Magic method to execute methods on get paramaters
81+
* Magic method to execute methods to return paramaters
8282
* For example, $source->sourceUrl executes $source->getSourceUrl().
8383
*
8484
* @param string $name The property name
@@ -94,6 +94,20 @@ public function __get($name)
9494
}
9595
}
9696

97+
/**
98+
* Magic method to execute methods to check if parameters are empty
99+
*
100+
* @param string $name The property name
101+
*
102+
* @return bool
103+
*/
104+
public function __isset($name)
105+
{
106+
$value = $this->$name;
107+
108+
return !empty($value);
109+
}
110+
97111
/**
98112
* Returns the dispatcher used.
99113
*

src/Embed.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public static function create($url, array $config = [], DispatcherInterface $dis
3030

3131
$info = self::process($url, $config, $dispatcher);
3232

33-
//if the canonical url is different, repeat the process
33+
// Repeat the process if:
34+
// - The canonical url is different
35+
// - No embed code has found
3436
$from = preg_replace('|^(\w+://)|', '', rtrim((string) $info->getResponse()->getUrl(), '/'));
3537
$to = preg_replace('|^(\w+://)|', '', rtrim($info->url, '/'));
3638

0 commit comments

Comments
 (0)