From c7ae29e0605c52f90fccf8afaa5afc033f065dbb Mon Sep 17 00:00:00 2001 From: Tadas Juozapaitis Date: Fri, 31 Jan 2014 17:34:28 +0200 Subject: [PATCH] bugs fixing --- README.md | 6 +++--- composer.json | 3 +++ src/LinkPreview/LinkPreview.php | 3 ++- src/LinkPreview/Parser/GeneralParser.php | 7 ------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 35583c6..dac052b 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,15 @@ $ php composer.phar install Library will be installed in vendor/kasp3r/link-preview -In your project include composer autoload file from vendor/.composer/autoload.php +In your project include composer autoload file from vendor/autoload.php ## Usage ```php $linkPreview = new LinkPreview('http://github.com'); -$parsed = $link->getParsed(); +$parsed = $linkPreview->getParsed(); foreach ($parsed as $parserName => $link) { - echo $parserName . PHP_EOL . PHP_EOL + echo $parserName . PHP_EOL . PHP_EOL; echo $link->getUrl() . PHP_EOL; echo $link->getRealUrl() . PHP_EOL; diff --git a/composer.json b/composer.json index e7c9e78..67670be 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,9 @@ "php": ">=5.3.0", "guzzle/guzzle": "~3.8" }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, "autoload": { "psr-0": { "LinkPreview": "src/" diff --git a/src/LinkPreview/LinkPreview.php b/src/LinkPreview/LinkPreview.php index 48b1018..6111187 100644 --- a/src/LinkPreview/LinkPreview.php +++ b/src/LinkPreview/LinkPreview.php @@ -185,7 +185,8 @@ public function getParsed() { $parsed = array(); - if (null === $this->getParsers()) { + $parsers = $this->getParsers(); + if (empty($parsers)) { $this->addDefaultParsers(); } diff --git a/src/LinkPreview/Parser/GeneralParser.php b/src/LinkPreview/Parser/GeneralParser.php index f60b779..23c0dfc 100644 --- a/src/LinkPreview/Parser/GeneralParser.php +++ b/src/LinkPreview/Parser/GeneralParser.php @@ -76,13 +76,6 @@ public function isValidParser() */ public function parseLink() { - $reader = $this->getReader(); - $reader - ->setLink($this->getLink()) - ->readLink(); - - $this->setLink($reader->getLink()); - $link = $this->getLink(); if (!strncmp($link->getContentType(), 'text/', strlen('text/'))) {