Commit ae8dc18f authored by Connor Tumbleson's avatar Connor Tumbleson Committed by StyleCI Bot

Apply fixes from StyleCI

[ci skip] [skip ci]
parent baa50e2b
Pipeline #986 skipped
......@@ -141,7 +141,7 @@ class MessageGenerator
}
/**
* @param User $user
* @param User $user
* @param GameEvent $event
* @param $char
*
......@@ -181,11 +181,11 @@ class MessageGenerator
private static function _buildSingleEventRow(&$count, $attendee, $event, $msg)
{
if ($event->isDestiny()) {
$msg .= $count++ . ') - <a href="' . \URL::action('Destiny\ProfileController@index', [$attendee->account->accountType, $attendee->account->seo, $attendee->character->characterId]) .
'">' . $attendee->account->gamertag . '</a> (' . $attendee->character->name() . ')<br />';
$msg .= $count++.') - <a href="'.\URL::action('Destiny\ProfileController@index', [$attendee->account->accountType, $attendee->account->seo, $attendee->character->characterId]).
'">'.$attendee->account->gamertag.'</a> ('.$attendee->character->name().')<br />';
} elseif ($event->isDestiny2()) {
$msg .= $count++ . ') - <a href="' . \URL::action('Destiny2\ProfileController@index', [$attendee->account->accountType, $attendee->account->seo, $attendee->d2character->characterId]) .
'">' . $attendee->account->gamertag . '</a> (' . $attendee->d2character->nameWithLight() . ')<br />';
$msg .= $count++.') - <a href="'.\URL::action('Destiny2\ProfileController@index', [$attendee->account->accountType, $attendee->account->seo, $attendee->d2character->characterId]).
'">'.$attendee->account->gamertag.'</a> ('.$attendee->d2character->nameWithLight().')<br />';
} elseif ($event->isOverwatch()) {
$msg .= $count++.') - <a href="'.\URL::action('Overwatch\ProfileController@index', [$attendee->account->seo, $attendee->account->accountType]).
'">'.$attendee->account->gamertag.'</a> ('.$attendee->ow->totalLevel().')<br />';
......
......@@ -23,13 +23,14 @@ class Client extends Http
/**
* @param $type
* @param $hash
*
* @return mixed
*/
public function getHash($type, $hash)
{
$instance = array_get(static::$instances, "$type.$hash");
if (! $instance) {
if (!$instance) {
$storage = storage_path('d2');
if (!\File::exists($storage)) {
......@@ -40,13 +41,14 @@ class Client extends Http
\File::makeDirectory($storage.'/'.$type, 0775, true);
}
$file = $storage . '/' . $type . '/' . $hash . '.php';
$file = $storage.'/'.$type.'/'.$hash.'.php';
if (\File::exists($file)) {
return include $file;
}
$data = $this->getEntity($type, $hash);
\File::put($file, '<?php return '.var_export($data, true).";\n");
return $data;
}
......@@ -56,8 +58,10 @@ class Client extends Http
/**
* @param $gamertag
* @param int $platform
* @return Account
*
* @throws Bungie2OfflineException
*
* @return Account
*/
public function getAccountByName($gamertag, $platform = 1)
{
......@@ -73,8 +77,8 @@ class Client extends Http
if ($account === null) {
$account = Account::firstOrCreate([
'gamertag' => $gamertag,
'accountType' => $platform
'gamertag' => $gamertag,
'accountType' => $platform,
]);
} else {
$account->gamertag = $gamertag;
......@@ -83,7 +87,7 @@ class Client extends Http
$results = $this->searchDestinyPlayer($gamertag, $platform);
$membershipId = null;
foreach($results as $result) {
foreach ($results as $result) {
if ($result['membershipType'] == $platform) {
$membershipId = $result['membershipId'];
}
......@@ -110,6 +114,7 @@ class Client extends Http
/**
* @param Account $account
*
* @return Account
*/
public function updateAccount(Account $account)
......@@ -133,23 +138,24 @@ class Client extends Http
return Character::updateOrCreate([
'characterId' => $character['characterId'],
], [
'characterId' => $character['characterId'],
'lastPlayed' => $character['dateLastPlayed'],
'characterId' => $character['characterId'],
'lastPlayed' => $character['dateLastPlayed'],
'minutesPlayedTotal' => $character['minutesPlayedTotal'],
'light' => $character['light'],
'raceHash' => $character['raceHash'],
'genderHash' => $character['genderHash'],
'classHash' => $character['classHash'],
'emblemPath' => $character['emblemPath'],
'backgroundPath' => $character['emblemBackgroundPath'],
'emblemHash' => $character['emblemHash'],
'level' => $character['baseCharacterLevel']
'light' => $character['light'],
'raceHash' => $character['raceHash'],
'genderHash' => $character['genderHash'],
'classHash' => $character['classHash'],
'emblemPath' => $character['emblemPath'],
'backgroundPath' => $character['emblemBackgroundPath'],
'emblemHash' => $character['emblemHash'],
'level' => $character['baseCharacterLevel'],
]);
}
/**
* @param Account $account
* @param array $data
* @param array $data
*
* @return mixed
*/
private function updateOrCreateData(Account $account, array $data)
......@@ -162,21 +168,23 @@ class Client extends Http
$character_3 = $characterIds[2] ?? null;
return Data::updateOrCreate([
'account_id' => $account->id
], [
'account_id' => $account->id,
], [
'account_id' => $account->id,
'membershipId' => $membershipId,
'character_1' => $character_1,
'character_2' => $character_2,
'character_3' => $character_3
'character_1' => $character_1,
'character_2' => $character_2,
'character_3' => $character_3,
]);
}
/**
* @param $membershipType
* @param $membershipId
* @return mixed
*
* @throws Bungie2OfflineException
*
* @return mixed
*/
private function getProfile($membershipType, $membershipId)
{
......@@ -194,8 +202,10 @@ class Client extends Http
/**
* @param $gamertag
* @param $platform
* @return mixed
*
* @throws Bungie2OfflineException
*
* @return mixed
*/
private function searchDestinyPlayer($gamertag, $platform)
{
......@@ -214,8 +224,10 @@ class Client extends Http
/**
* @param $type
* @param $hash
* @return mixed
*
* @throws Bungie2OfflineException
*
* @return mixed
*/
private function getEntity($type, $hash)
{
......@@ -233,6 +245,7 @@ class Client extends Http
/**
* @param $gamertag
* @param $platform
*
* @return Account
*/
private function checkCacheForTag($gamertag, $platform)
......@@ -246,7 +259,6 @@ class Client extends Http
return $account;
}
}
class PlayerNotFoundException extends \Exception
......
......@@ -5,8 +5,7 @@ namespace Onyx\Destiny2\Helpers\String;
use Onyx\Destiny2\Client;
/**
* Class Hashes
* @package Onyx\Destiny2\Helpers\String
* Class Hashes.
*/
class Hashes
{
......@@ -26,6 +25,7 @@ class Hashes
/**
* @param $type
* @param $hash
*
* @return mixed
*/
public static function getHash($type, $hash)
......@@ -33,6 +33,7 @@ class Hashes
if (self::$client === null) {
self::$client = new Client();
}
return self::$client->getHash($type, $hash);
}
}
\ No newline at end of file
}
......@@ -71,7 +71,7 @@ class Character extends Model
public function nameWithLight()
{
return $this->name().' - ' . $this->max_light;
return $this->name().' - '.$this->max_light;
}
public function emblem()
......@@ -89,6 +89,7 @@ class Character extends Model
private function destinyClass()
{
$hash = Hashes::getHash('DestinyClassDefinition', $this->classHash);
return array_get($hash, 'displayProperties.name');
}
}
......@@ -40,7 +40,6 @@ class Data extends Model
// Accessors & Mutators
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
// Public Methods
//---------------------------------------------------------------------------------
......@@ -53,7 +52,7 @@ class Data extends Model
return [
$this->character1,
$this->character2,
$this->character3
$this->character3,
];
}
......@@ -65,7 +64,7 @@ class Data extends Model
return [
$this->character1,
$this->character2,
$this->character3
$this->character3,
];
}
......
......@@ -77,11 +77,13 @@ class CustomValidator extends Validator
public function validateDestiny2TagExists($attribute, $value, $parameters)
{
$client = new Destiny2Client();
try {
$account = $client->getAccountByName($value, $this->data['platform']);
} catch (Bungie2OfflineException $ex) {
return false;
}
return true;
}
......@@ -122,6 +124,7 @@ class CustomValidator extends Validator
// lets try for a D2 one now
try {
$character = \Onyx\Destiny2\Objects\Character::where('characterId', $value)->firstOrFail();
return true;
} catch (ModelNotFoundException $ex) {
return false;
......
......@@ -97,7 +97,6 @@ class AccountController extends Controller
$account = $client->getAccountByName($gamertag, $platform);
return \Redirect::action('Destiny2\ProfileController@index', [$account->accountType, $account->seo]);
} catch (\Exception $ex) {
return redirect('/account')
->with('flash_message', [
......
......@@ -50,14 +50,14 @@ class ApiV1Controller extends Controller
$p = [];
foreach ($pandas as $panda) {
foreach ($panda->destiny2->characters() as $character) {
if (! $character instanceof Character) {
if (!$character instanceof Character) {
continue;
}
if ($character->max_light > 240) {
$p[$character->max_light][] = [
'name' => $panda->gamertag .' ('.$character->name().')',
'name' => $panda->gamertag.' ('.$character->name().')',
'maxLight' => $character->max_light,
'light' => $character->light
'light' => $character->light,
];
}
}
......@@ -110,7 +110,7 @@ class ApiV1Controller extends Controller
$msg = 'Stats for: <strong>'.$user->account->gamertag.'</strong> have been updated. <br /><br />';
foreach ($user->account->destiny2->characters() as $character) {
$msg .= $character->name() . ' - ' . $character->max_light. '<br />';
$msg .= $character->name().' - '.$character->max_light.'<br />';
}
return Response::json([
......
......@@ -36,7 +36,7 @@ class ProfileController extends Controller
}
return view('destiny2.profile', [
'account' => $account
'account' => $account,
]);
} catch (ModelNotFoundException $e) {
\App::abort(404, 'Da Gone!!! We have no idea what you are looking for.');
......
......@@ -17,7 +17,7 @@ class VerifyCsrfToken extends BaseVerifier
'xbox/api/*',
'h5/api/*',
'overwatch/api/*',
'destiny2/api/*'
'destiny2/api/*',
];
/**
......
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddDestiny2Tables extends Migration
{
......
......@@ -108,7 +108,7 @@ class enforceTimezoneEventCreationTest extends TestCase
$gameEvent = \Onyx\Calendar\Objects\Event::find($json['id']);
$diff = Carbon::now('America/Chicago')->diffInSeconds($gameEvent->start, false);
$this->assertTrue($diff > 600, 'This is at '. $diff);
$this->assertTrue($diff > 600, 'This is at '.$diff);
$this->assertEquals($gameEvent->botDate(), $date->format('M j (D) - g:ia T'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment