From f5e9c8781cce28cfa6c9789af32f1ce75f58b614 Mon Sep 17 00:00:00 2001 From: Eric Wheeler Date: Fri, 23 Dec 2016 12:05:56 -0800 Subject: [PATCH] Added image collection --- composer.json | 3 +- composer.lock | 70 ++++++++++++++++++- .../Tor/Collection/ImageCollection.php | 37 ++++++++++ src/Sikofitt/Tor/TorClient.php | 8 +++ 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 src/Sikofitt/Tor/Collection/ImageCollection.php diff --git a/composer.json b/composer.json index aac9222..5780083 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "symfony/css-selector": "^2.8", "symfony/process": "^2.8", "symfony/dom-crawler": "^2.8", - "symfony/console": "^2.8" + "symfony/console": "^2.8", + "doctrine/collections": "^1.3" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index e0d6083..c142896 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,75 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f32953690bad3de29ca6b2542acc1b29", - "content-hash": "149eb0993f5007ea0ffa28c7f9762f3b", + "hash": "439da2eb89743fa1d87cf656df00dd7b", + "content-hash": "83d61f647d294058c67c53ea5fab1dc9", "packages": [ + { + "name": "doctrine/collections", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2015-04-14 22:21:58" + }, { "name": "guzzlehttp/guzzle", "version": "6.2.2", diff --git a/src/Sikofitt/Tor/Collection/ImageCollection.php b/src/Sikofitt/Tor/Collection/ImageCollection.php new file mode 100644 index 0000000..0b1979d --- /dev/null +++ b/src/Sikofitt/Tor/Collection/ImageCollection.php @@ -0,0 +1,37 @@ +html = $html; + $this->images = new ArrayCollection(); + $this->crawler = new Crawler(); + } + + public function images() + { + $this->crawler->addHtmlContent($this->html); + $images = $this->crawler->filter('img'); + foreach($images as $image) { + $this->images->add(new ArrayCollection($image->attributes)); + } + return $this->images; + } +} \ No newline at end of file diff --git a/src/Sikofitt/Tor/TorClient.php b/src/Sikofitt/Tor/TorClient.php index cf35203..0711359 100644 --- a/src/Sikofitt/Tor/TorClient.php +++ b/src/Sikofitt/Tor/TorClient.php @@ -78,10 +78,18 @@ class TorClient ]); return $this; } + + /** + * @return $this + */ public function setTorMiddleWare() { $this->middleware = Middleware::tor($this->proxy, $this->torControl); return $this; } + + /** + * + */ public function createHandlerStack() { $this->handlerStack = new HandlerStack();