Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19 from findbrok/master
Browse files Browse the repository at this point in the history
Fix some issues with Warning Model and new format of contentItem
  • Loading branch information
percymamedy authored Jul 15, 2017
2 parents 2b6e7d9 + b32054e commit 0ee7832
Show file tree
Hide file tree
Showing 9 changed files with 7,027 additions and 9,074 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=5.5.0",
"php": ">=5.6.0",
"findbrok/php-watson-api-bridge": "^1.0",
"illuminate/support": "~5.0",
"netresearch/jsonmapper": "^1.1",
Expand Down
19 changes: 10 additions & 9 deletions src/AbstractPersonalityInsights.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public function getCredentialsName()
*/
public function getApiVersion()
{
return $this->getAccessManager()->getApiVersion();
return $this->getAccessManager()
->getApiVersion();
}

/**
Expand All @@ -128,9 +129,9 @@ public function getApiVersion()
protected function getHeaders()
{
// Return headers.
return collect($this->headers)
->merge(['X-Watson-Learning-Opt-Out' => config('personality-insights.x_watson_learning_opt_out')])
->all();
return collect($this->headers)->merge([
'X-Watson-Learning-Opt-Out' => config('personality-insights.x_watson_learning_opt_out'),
])->all();
}

/**
Expand Down Expand Up @@ -264,10 +265,10 @@ public function makeBridge()
*/
public function addSingleContentItem($items = [])
{
//Push ContentItem in ContentListContainer
// Push ContentItem in ContentListContainer.
$this->contentListContainer->push($items instanceof ContentItem ? $items : personality_insights_content_item($items));

//Return object
// Return object.
return $this;
}

Expand All @@ -280,13 +281,13 @@ public function addSingleContentItem($items = [])
*/
public function addContentItems($items = [])
{
//Loop on each item
// Loop on each item.
collect($items)->each(function ($item) {
//Add each content to the Container
// Add each content to the Container.
$this->addSingleContentItem($item);
});

//Return object
// Return object.
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Warning.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Warning
/**
* The identifier of the warning message, one of WORD_COUNT_MESSAGE, JSON_AS_TEXT, or PARTIAL_TEXT_USED.
*
* @var
* @var string
*/
public $warning_id;

Expand Down
40 changes: 13 additions & 27 deletions src/Support/DataCollector/ContentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,6 @@ class ContentItem extends Collection

'content' => '',

/*
|--------------------------------------------------------------------------
| userid [string] | (Optional)
|--------------------------------------------------------------------------
|
| A unique identifier for the author of this content
|
*/

'userid' => '',

/*
|--------------------------------------------------------------------------
| sourceid [string] | (Optional)
|--------------------------------------------------------------------------
|
| An identifier for the source of this content; for example, blog123 or twitter
|
*/

'sourceid' => '',

/*
|--------------------------------------------------------------------------
| created [integer] | (Optional)
Expand Down Expand Up @@ -152,17 +130,25 @@ class ContentItem extends Collection
/**
* Create a new ContentItem.
*
*
* @param array $items
*
* @throws MissingParameterContentItemException
*/
public function __construct($items = [])
{
//New Up parent
// New Up parent.
parent::__construct($items);

//If we do not have content then throw an Exception
// Validates the ContentItem.
$this->validates();
}

/**
* Validates the ContentItem.
*
* @throws MissingParameterContentItemException
*/
protected function validates()
{
// If we do not have content then throw an Exception.
if (! $this->has('content')) {
throw new MissingParameterContentItemException('Personality Insights requires a content', 422);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Support/DataCollector/ContentListContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class ContentListContainer extends Collection
const SERVICE_ID = 'PIContentListContainer';

/**
* {@inheritdoc}
* ContentListContainer constructor.
*
* @param array $items
*/
public function __construct($items = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
function personality_insights_content_item($item = [])
{
//Return new content item
// Return new content item.
return new DataCollector\ContentItem($item);
}
}
Loading

0 comments on commit 0ee7832

Please sign in to comment.