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

Commit

Permalink
Merge branch 'master' into 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
percymamedy committed Nov 5, 2016
2 parents f074b90 + 055e42b commit 864a314
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 49 deletions.
7 changes: 7 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
preset: laravel

disabled:
- concat_without_spaces

enabled:
- concat_with_spaces
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/f61e9357-250f-4816-b6c0-ae1ec0bcaa42/big.png)](https://insight.sensiolabs.com/projects/f61e9357-250f-4816-b6c0-ae1ec0bcaa42)

[![StyleCI](https://styleci.io/repos/59981815/shield?style=flat)](https://styleci.io/repos/59981815)
[![Dependency Status](https://dependencyci.com/github/findbrok/laravel-tradeoff-analytics/badge)](https://dependencyci.com/github/findbrok/laravel-tradeoff-analytics)
[![Build Status](https://travis-ci.org/findbrok/laravel-tradeoff-analytics.svg?branch=master)](https://travis-ci.org/findbrok/laravel-tradeoff-analytics)
[![Latest Stable Version](https://poser.pugx.org/findbrok/laravel-tradeoff-analytics/v/stable)](https://packagist.org/packages/findbrok/laravel-tradeoff-analytics)
[![Total Downloads](https://poser.pugx.org/findbrok/laravel-tradeoff-analytics/downloads)](https://packagist.org/packages/findbrok/laravel-tradeoff-analytics)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"php": ">=5.5.0",
"findbrok/php-watson-api-bridge": "1.0.*",
"laravel/framework": "5.0.*|5.1.*|5.2.*",
"laravel/framework": "5.0 - 5.3",
"nesbot/carbon": "1.21.*"
},
"require-dev": {
Expand Down
6 changes: 3 additions & 3 deletions src/AbstractEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public function getCredentialName()
public function getCredentials()
{
return [
'username' => config('tradeoff-analytics.credentials.'.$this->getCredentialName().'.username'),
'password' => config('tradeoff-analytics.credentials.'.$this->getCredentialName().'.password'),
'url' => config('tradeoff-analytics.credentials.'.$this->getCredentialName().'.url'),
'username' => config('tradeoff-analytics.credentials.' . $this->getCredentialName() . '.username'),
'password' => config('tradeoff-analytics.credentials.' . $this->getCredentialName() . '.password'),
'url' => config('tradeoff-analytics.credentials.' . $this->getCredentialName() . '.url'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getDilemma(Problem $problem, $generateVisualization = true)
{
//Get Response from Watson
$response = $this->makeBridge()->post(
'v1/dilemmas?generate_visualization='.var_export($generateVisualization, true),
'v1/dilemmas?generate_visualization=' . var_export($generateVisualization, true),
$problem->statement()
);
//Get Response content
Expand Down
8 changes: 4 additions & 4 deletions src/Support/DataCollection/BaseCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct($items = [])
*/
public function hasSupportedFields()
{
return property_exists($this, 'supportedFields') && !empty($this->supportedFields);
return property_exists($this, 'supportedFields') && ! empty($this->supportedFields);
}

/**
Expand All @@ -52,7 +52,7 @@ public function isFieldSupported($field)
public function filterOutUnsupported($items = [])
{
return collect($items)->reject(function ($item, $key) {
return $this->hasSupportedFields() && !in_array($key, $this->supportedFields);
return $this->hasSupportedFields() && ! in_array($key, $this->supportedFields);
})->all();
}

Expand All @@ -69,7 +69,7 @@ public function filterOutUnsupported($items = [])
public function put($key, $value)
{
//Field not supported
if (!$this->isFieldSupported($key)) {
if (! $this->isFieldSupported($key)) {
throw new DataCollectionUnsupportedFieldException($key, get_class($this));
}
//Parent Put
Expand Down Expand Up @@ -99,7 +99,7 @@ public function merge($items)
public function add($items = [])
{
//Column not empty
if (!$this->isEmpty()) {
if (! $this->isEmpty()) {
$this->items = $this->merge($items)->all();

return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/DataCollection/BaseCollectorRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BaseCollectorRange extends BaseCollector
public function __construct($items = [])
{
//We have range
if (!empty($items)) {
if (! empty($items)) {
$this->defineRange($this->filterOutUnsupported($items));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Support/DataCollection/Dilemma.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Dilemma extends Collection
*/
public function hasProblem()
{
return $this->has('problem') && !collect($this->get('problem'))->isEmpty();
return $this->has('problem') && ! collect($this->get('problem'))->isEmpty();
}

/**
Expand All @@ -40,7 +40,7 @@ public function getProblem()
*/
public function hasResolution()
{
return $this->has('resolution') && !collect($this->get('resolution'))->isEmpty();
return $this->has('resolution') && ! collect($this->get('resolution'))->isEmpty();
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Support/DataCollection/Problem.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Problem extends BaseCollector
*/
protected function validateColumnField($item)
{
if (!$item instanceof ProblemColumn) {
if (! $item instanceof ProblemColumn) {
throw new DataCollectionFieldMissMatchTypeException('columns', 'Problem', 'ProblemColumn');
}
}
Expand All @@ -82,7 +82,7 @@ protected function validateColumnField($item)
*/
protected function validateOptionField($item)
{
if (!$item instanceof ProblemOption) {
if (! $item instanceof ProblemOption) {
throw new DataCollectionFieldMissMatchTypeException('options', 'Problem', 'ProblemOption');
}
}
Expand Down Expand Up @@ -164,15 +164,15 @@ public function objectifyColumns()
{
//Objectify each column
$columns = collect($this->get('columns'))->transform(function ($item) {
if (!$item instanceof ProblemColumn) {
if (! $item instanceof ProblemColumn) {
return make_tradeoff_problem_column($item);
}

return $item;
});

//Put in field if we have items
if (!$columns->isEmpty()) {
if (! $columns->isEmpty()) {
$this->put('columns', $columns->all());
}

Expand All @@ -188,15 +188,15 @@ public function objectifyOptions()
{
//Objectify each column options
$options = collect($this->get('options'))->transform(function ($item) {
if (!$item instanceof ProblemOption) {
if (! $item instanceof ProblemOption) {
return make_tradeoff_problem_option($item);
}

return $item;
});

//Put in field if we have items
if (!$options->isEmpty()) {
if (! $options->isEmpty()) {
$this->put('options', $options->all());
}

Expand Down
4 changes: 2 additions & 2 deletions src/Support/DataCollection/ProblemColumnDateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public function defineRange($range = [])
//Collect range
$range = collect($range);
//Validate Range
if (!$range->has('high') && !$range->has('low')) {
if (! $range->has('high') && ! $range->has('low')) {
throw new Exception('Missing {high} or {low} field in {ProblemColumnDateRange} object', 422);
}
//Transform to toIso8601String
$this->items = $range->transform(function ($item, $key) {
if (!$item instanceof Carbon) {
if (! $item instanceof Carbon) {
throw new DataCollectionFieldMissMatchTypeException($key, 'ProblemColumnCategoricalRange', 'Carbon\Carbon');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Support/DataCollection/ProblemColumnValueRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function defineRange($range = [])
//Collect range
$range = collect($range);
//Validate Range
if (!$range->has('high') && !$range->has('low')) {
if (! $range->has('high') && ! $range->has('low')) {
throw new Exception('Missing {high} or {low} field in {ProblemColumnValueRange} object', 422);
}
//Transform to int
Expand Down
8 changes: 4 additions & 4 deletions src/Support/DataCollection/Resolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function findSolution($solutionRef)
true
) : null;

return !empty($solution) ? $solution[0] : null;
return ! empty($solution) ? $solution[0] : null;
}

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ public function getSolutionsBeingShadowedBy($solutionRef)
*/
public function hasSolutions()
{
return $this->has('solutions') && !collect($this->get('solutions'))->isEmpty();
return $this->has('solutions') && ! collect($this->get('solutions'))->isEmpty();
}

/**
Expand All @@ -101,7 +101,7 @@ public function objectifySolutions($solutions = [], $objectify = false)
//Transform to objects
if ($objectify) {
return collect($solutions)->transform(function ($item) {
if (!$item instanceof Solution) {
if (! $item instanceof Solution) {
return make_tradeoff_solution($item);
}

Expand Down Expand Up @@ -192,7 +192,7 @@ public function getUnmetCategoricalPreferenceSolutions($objectify = false)
*/
public function hasMap()
{
return $this->has('map') && !collect($this->get('map'))->isEmpty();
return $this->has('map') && ! collect($this->get('map'))->isEmpty();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Support/DataCollection/Solution.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function doesNotMeetPreference()
*/
public function isShadowedByOthers()
{
return $this->has('shadow_me') && !collect($this->get('shadow_me'))->isEmpty();
return $this->has('shadow_me') && ! collect($this->get('shadow_me'))->isEmpty();
}

/**
Expand All @@ -66,7 +66,7 @@ public function isShadowedByOthers()
*/
public function shadowsOthers()
{
return $this->has('shadows') && !collect($this->get('shadows'))->isEmpty();
return $this->has('shadows') && ! collect($this->get('shadows'))->isEmpty();
}

/**
Expand Down Expand Up @@ -96,7 +96,7 @@ public function getShadows()
*/
public function hasStatusCause()
{
return $this->has('status_cause') && !collect($this->get('status_cause'))->isEmpty();
return $this->has('status_cause') && ! collect($this->get('status_cause'))->isEmpty();
}

/**
Expand Down
28 changes: 14 additions & 14 deletions src/Support/helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if (!function_exists('make_tradeoff_problem')) {
if (! function_exists('make_tradeoff_problem')) {
/**
* Make a Tradeoff Analytics Problem object.
*
Expand All @@ -21,7 +21,7 @@ function make_tradeoff_problem($items = [], $objectify = false)
}
}

if (!function_exists('make_tradeoff_problem_column')) {
if (! function_exists('make_tradeoff_problem_column')) {
/**
* Make a Tradeoff Analytics ProblemColumn object.
*
Expand All @@ -35,7 +35,7 @@ function make_tradeoff_problem_column($items = [])
}
}

if (!function_exists('make_tradeoff_problem_option')) {
if (! function_exists('make_tradeoff_problem_option')) {
/**
* Make a Tradeoff Analytics ProblemOption object.
*
Expand All @@ -49,7 +49,7 @@ function make_tradeoff_problem_option($items = [])
}
}

if (!function_exists('make_tradeoff_problem_column_categorical_range')) {
if (! function_exists('make_tradeoff_problem_column_categorical_range')) {
/**
* Make a Tradeoff Analytics ProblemColumnCategoricalRange object.
*
Expand All @@ -63,7 +63,7 @@ function make_tradeoff_problem_column_categorical_range($items = [])
}
}

if (!function_exists('make_tradeoff_problem_column_date_range')) {
if (! function_exists('make_tradeoff_problem_column_date_range')) {
/**
* Make a Tradeoff analytics ProblemColumnDateRange object.
*
Expand All @@ -77,7 +77,7 @@ function make_tradeoff_problem_column_date_range($items = [])
}
}

if (!function_exists('make_tradeoff_problem_column_value_range')) {
if (! function_exists('make_tradeoff_problem_column_value_range')) {
/**
* Make a Tradeoff analytics ProblemColumnValueRange object.
*
Expand All @@ -91,7 +91,7 @@ function make_tradeoff_problem_column_value_range($items = [])
}
}

if (!function_exists('make_tradeoff_dilemma')) {
if (! function_exists('make_tradeoff_dilemma')) {
/**
* Make a Tradeoff analytics Dilemma Object.
*
Expand All @@ -105,7 +105,7 @@ function make_tradeoff_dilemma($items = [])
}
}

if (!function_exists('make_tradeoff_resolution')) {
if (! function_exists('make_tradeoff_resolution')) {
/**
* Make a Tradeoff Analytics Resolution Object.
*
Expand All @@ -119,7 +119,7 @@ function make_tradeoff_resolution($items = [])
}
}

if (!function_exists('make_tradeoff_solution')) {
if (! function_exists('make_tradeoff_solution')) {
/**
* Make a Tradeoff Analytics Solution Object.
*
Expand All @@ -133,7 +133,7 @@ function make_tradeoff_solution($items = [])
}
}

if (!function_exists('make_tradeoff_solution_status_cause')) {
if (! function_exists('make_tradeoff_solution_status_cause')) {
/**
* Make a Tradeoff Analytic SolutionStatusCause Object.
*
Expand All @@ -147,7 +147,7 @@ function make_tradeoff_solution_status_cause($item = [])
}
}

if (!function_exists('make_tradeoff_map')) {
if (! function_exists('make_tradeoff_map')) {
/**
* Make a Tradeoff Analytics Map Object.
*
Expand All @@ -161,7 +161,7 @@ function make_tradeoff_map($items = [])
}
}

if (!function_exists('make_tradeoff_map_anchor')) {
if (! function_exists('make_tradeoff_map_anchor')) {
/**
* Make a Tradeoff Analytics MapAnchor object.
*
Expand All @@ -175,7 +175,7 @@ function make_tradeoff_map_anchor($items = [])
}
}

if (!function_exists('make_tradeoff_map_node')) {
if (! function_exists('make_tradeoff_map_node')) {
/**
* Make a Tradeoff Analytics MapNode object.
*
Expand All @@ -189,7 +189,7 @@ function make_tradeoff_map_node($items = [])
}
}

if (!function_exists('make_tradeoff_map_node_coordinates')) {
if (! function_exists('make_tradeoff_map_node_coordinates')) {
/**
* Make a Tradeoff Analytics MapNodeCoordinates object.
*
Expand Down
2 changes: 1 addition & 1 deletion src/TradeoffAnalyticsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ public function registerDataCollections()
*/
public function ourConfigPath($fileName = '')
{
return __DIR__.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.$fileName;
return __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $fileName;
}
}
2 changes: 1 addition & 1 deletion tests/TestDilemma.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function getPackageProviders($app)
*/
public function getResolution()
{
return json_decode(file_get_contents(__DIR__.'/fixtures/resolution.json'), true);
return json_decode(file_get_contents(__DIR__ . '/fixtures/resolution.json'), true);
}

/**
Expand Down
Loading

0 comments on commit 864a314

Please sign in to comment.