Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
psr2
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 21, 2016
1 parent 55693b3 commit 5a0db95
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
13 changes: 6 additions & 7 deletions spec/Spatie/GoogleSearch/GoogleSearchSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
namespace spec\Spatie\GoogleSearch;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class GoogleSearchSpec extends ObjectBehavior
{
function let() {
public function let()
{
$this->beConstructedWith('search-engine-id');
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Spatie\GoogleSearch\GoogleSearch');
}

function it_should_throw_an_exception_when_called_with_an_empty_string()
public function it_should_throw_an_exception_when_called_with_an_empty_string()
{
$this->getResults('')->shouldHaveCount(0);
}

function it_should_throw_an_exception_when_no_valid_engine_id_is_set()
public function it_should_throw_an_exception_when_no_valid_engine_id_is_set()
{
$this->shouldThrow('\Exception')->during('getResults', array('test-query') );

$this->shouldThrow('\Exception')->during('getResults', array('test-query'));
}
}
5 changes: 3 additions & 2 deletions src/Spatie/GoogleSearch/Facades/GoogleSearch.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php namespace Spatie\GoogleSearch\Facades;
<?php

namespace Spatie\GoogleSearch\Facades;

use Illuminate\Support\Facades\Facade;

class GoogleSearch extends Facade
{

/**
* Get the registered name of the component.
*
Expand Down
20 changes: 12 additions & 8 deletions src/Spatie/GoogleSearch/GoogleSearch.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Spatie\GoogleSearch;
<?php

namespace Spatie\GoogleSearch;

use Exception;
use Spatie\GoogleSearch\Interfaces\GoogleSearchInterface;
Expand All @@ -15,12 +17,13 @@ public function __construct($searchEngineId)
}

/**
* Get results from a Google Custom Search Engine.
*
* @param string $query
*
* Get results from a Google Custom Search Engine
* @return array An associative array of the parsed comment, whose keys are `name`,
* `url` and `snippet` and some others
*
* @param string $query
* @return array An associative array of the parsed comment, whose keys are `name`,
* `url` and `snippet` and some others
* @throws Exception
*/
public function getResults($query)
Expand Down Expand Up @@ -67,26 +70,27 @@ public function getResults($query)
$searchResults[$i]['offer']['price'] = $this->getPageMapProperty($item, 'offer', 'price');
$searchResults[$i]['offer']['pricecurrency'] = $this->getPageMapProperty($item, 'offer', 'pricecurrency');

$i++;
++$i;
}
}

return $searchResults;
}

/**
* Get a the value Pagemap property with the given name of the given type of the given item
* Get a the value Pagemap property with the given name of the given type of the given item.
*
* @param $item
* @param $type
* @param $attribute
*
* @return string
*/
public function getPageMapProperty($item, $type, $attribute)
{
$propertyArray = $item->PageMap->xpath('DataObject[@type="'.$type.'"]/Attribute[@name="'.$attribute.'"]/@value');

if (! count($propertyArray)) {
if (!count($propertyArray)) {
return '';
}

Expand Down
5 changes: 3 additions & 2 deletions src/Spatie/GoogleSearch/GoogleSearchServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php namespace Spatie\GoogleSearch;
<?php

namespace Spatie\GoogleSearch;

use Illuminate\Support\ServiceProvider;

class GoogleSearchServiceProvider extends ServiceProvider
{

public function boot()
{
$this->publishes([
Expand Down
4 changes: 3 additions & 1 deletion src/Spatie/GoogleSearch/Interfaces/GoogleSearchInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Spatie\GoogleSearch\Interfaces;
<?php

namespace Spatie\GoogleSearch\Interfaces;

interface GoogleSearchInterface
{
Expand Down
1 change: 1 addition & 0 deletions src/config/googleSearch.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php

return array('searchEngineId' => '');

0 comments on commit 5a0db95

Please sign in to comment.