Add strict types and newlines.

This commit is contained in:
James Cole 2018-05-05 16:51:32 +02:00
parent 3ac240dc1c
commit f74b9ba7ab
29 changed files with 347 additions and 270 deletions

View File

@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
/**
* FileJobConfiguration.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Import\JobConfiguration;
use FireflyIII\Models\ImportJob;
use Illuminate\Support\MessageBag;
class FileJobConfiguration implements JobConfigurationInterface
{
/**
* ConfiguratorInterface constructor.
*/
public function __construct()
{
}
/**
* Store any data from the $data array into the job. Anything in the message bag will be flashed
* as an error to the user, regardless of its content.
*
* @param array $data
*
* @return MessageBag
*/
public function configureJob(array $data): MessageBag
{
// TODO: Implement configureJob() method.
}
/**
* Return the data required for the next step in the job configuration.
*
* @return array
*/
public function getNextData(): array
{
// TODO: Implement getNextData() method.
}
/**
* Returns the view of the next step in the job configuration.
*
* @return string
*/
public function getNextView(): string
{
// TODO: Implement getNextView() method.
}
/**
* Returns true when the initial configuration for this job is complete.
*
* @return bool
*/
public function configurationComplete(): bool
{
// TODO: Implement configurationComplete() method.
}
/**
* @param ImportJob $job
*/
public function setJob(ImportJob $job): void
{
// TODO: Implement setJob() method.
}
}

View File

@ -36,146 +36,146 @@ use Preferences;
*/
class BunqPrerequisites implements PrerequisitesInterface
{
// /** @var User */
// private $user;
//
// /**
// * Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
// *
// * @return string
// */
// public function getView(): string
// {
// Log::debug('Now in BunqPrerequisites::getView()');
//
// return 'import.bunq.prerequisites';
// }
//
// /**
// * Returns any values required for the prerequisites-view.
// *
// * @return array
// */
// public function getViewParameters(): array
// {
// Log::debug('Now in BunqPrerequisites::getViewParameters()');
// $key = '';
// $serverIP = '';
// if ($this->hasApiKey()) {
// $key = Preferences::getForUser($this->user, 'bunq_api_key', null)->data;
// }
// if ($this->hasServerIP()) {
// $serverIP = Preferences::getForUser($this->user, 'external_ip', null)->data;
// }
// if (!$this->hasServerIP()) {
// /** @var IPRetrievalInterface $service */
// $service = app(IPRetrievalInterface::class);
// $serverIP = (string)$service->getIP();
// }
//
//
// // get IP address
// return ['key' => $key, 'ip' => $serverIP];
// }
//
// /**
// * Returns if this import method has any special prerequisites such as config
// * variables or other things. The only thing we verify is the presence of the API key. Everything else
// * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
// *
// * @return bool
// */
// public function hasPrerequisites(): bool
// {
// $hasApiKey = $this->hasApiKey();
// $hasServerIP = $this->hasServerIP();
//
// return !$hasApiKey || !$hasServerIP;
// }
//
// /**
// * Indicate if all prerequisites have been met.
// *
// * @return bool
// */
// public function isComplete(): bool
// {
// // is complete when user has entered both the API key
// // and his IP address.
//
// $hasApiKey = $this->hasApiKey();
// $hasServerIP = $this->hasServerIP();
//
// return $hasApiKey && $hasServerIP;
// }
//
// /**
// * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
// *
// * @param User $user
// */
// public function setUser(User $user): void
// {
// Log::debug(sprintf('Now in setUser(#%d)', $user->id));
// $this->user = $user;
// }
//
// /**
// * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
// * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
// *
// * @param Request $request
// *
// * @return MessageBag
// */
// public function storePrerequisites(Request $request): MessageBag
// {
// $apiKey = $request->get('api_key');
// $serverIP = $request->get('external_ip');
// Log::debug('Storing bunq API key');
// Preferences::setForUser($this->user, 'bunq_api_key', $apiKey);
// Preferences::setForUser($this->user, 'external_ip', $serverIP);
//
// return new MessageBag;
// }
//
// /**
// * @return bool
// */
// private function hasApiKey(): bool
// {
// $apiKey = Preferences::getForUser($this->user, 'bunq_api_key', false);
// if (null === $apiKey) {
// return false;
// }
// if (null === $apiKey->data) {
// return false;
// }
// if (\strlen((string)$apiKey->data) === 64) {
// return true;
// }
//
// return false;
// }
//
// /**
// * @return bool
// */
// private function hasServerIP(): bool
// {
// $serverIP = Preferences::getForUser($this->user, 'external_ip', false);
// if (null === $serverIP) {
// return false;
// }
// if (null === $serverIP->data) {
// return false;
// }
// if (\strlen((string)$serverIP->data) > 6) {
// return true;
// }
//
// return false;
// }
/** @var User */
private $user;
//
// /**
// * Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
// *
// * @return string
// */
// public function getView(): string
// {
// Log::debug('Now in BunqPrerequisites::getView()');
//
// return 'import.bunq.prerequisites';
// }
//
// /**
// * Returns any values required for the prerequisites-view.
// *
// * @return array
// */
// public function getViewParameters(): array
// {
// Log::debug('Now in BunqPrerequisites::getViewParameters()');
// $key = '';
// $serverIP = '';
// if ($this->hasApiKey()) {
// $key = Preferences::getForUser($this->user, 'bunq_api_key', null)->data;
// }
// if ($this->hasServerIP()) {
// $serverIP = Preferences::getForUser($this->user, 'external_ip', null)->data;
// }
// if (!$this->hasServerIP()) {
// /** @var IPRetrievalInterface $service */
// $service = app(IPRetrievalInterface::class);
// $serverIP = (string)$service->getIP();
// }
//
//
// // get IP address
// return ['key' => $key, 'ip' => $serverIP];
// }
//
// /**
// * Returns if this import method has any special prerequisites such as config
// * variables or other things. The only thing we verify is the presence of the API key. Everything else
// * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
// *
// * @return bool
// */
// public function hasPrerequisites(): bool
// {
// $hasApiKey = $this->hasApiKey();
// $hasServerIP = $this->hasServerIP();
//
// return !$hasApiKey || !$hasServerIP;
// }
//
// /**
// * Indicate if all prerequisites have been met.
// *
// * @return bool
// */
// public function isComplete(): bool
// {
// // is complete when user has entered both the API key
// // and his IP address.
//
// $hasApiKey = $this->hasApiKey();
// $hasServerIP = $this->hasServerIP();
//
// return $hasApiKey && $hasServerIP;
// }
//
// /**
// * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
// *
// * @param User $user
// */
// public function setUser(User $user): void
// {
// Log::debug(sprintf('Now in setUser(#%d)', $user->id));
// $this->user = $user;
// }
//
// /**
// * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
// * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
// *
// * @param Request $request
// *
// * @return MessageBag
// */
// public function storePrerequisites(Request $request): MessageBag
// {
// $apiKey = $request->get('api_key');
// $serverIP = $request->get('external_ip');
// Log::debug('Storing bunq API key');
// Preferences::setForUser($this->user, 'bunq_api_key', $apiKey);
// Preferences::setForUser($this->user, 'external_ip', $serverIP);
//
// return new MessageBag;
// }
//
// /**
// * @return bool
// */
// private function hasApiKey(): bool
// {
// $apiKey = Preferences::getForUser($this->user, 'bunq_api_key', false);
// if (null === $apiKey) {
// return false;
// }
// if (null === $apiKey->data) {
// return false;
// }
// if (\strlen((string)$apiKey->data) === 64) {
// return true;
// }
//
// return false;
// }
//
// /**
// * @return bool
// */
// private function hasServerIP(): bool
// {
// $serverIP = Preferences::getForUser($this->user, 'external_ip', false);
// if (null === $serverIP) {
// return false;
// }
// if (null === $serverIP->data) {
// return false;
// }
// if (\strlen((string)$serverIP->data) > 6) {
// return true;
// }
//
// return false;
// }
/**
* Returns view name that allows user to fill in prerequisites.
*
@ -183,8 +183,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/
public function getView(): string
{
// TODO: Implement getView() method.
throw new NotImplementedException;
return 'todo';
}
/**
@ -194,8 +193,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/
public function getViewParameters(): array
{
// TODO: Implement getViewParameters() method.
throw new NotImplementedException;
return [];
}
/**
@ -205,8 +203,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/
public function isComplete(): bool
{
// TODO: Implement isComplete() method.
throw new NotImplementedException;
return false;
}
/**
@ -216,8 +213,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/
public function setUser(User $user): void
{
// TODO: Implement setUser() method.
throw new NotImplementedException;
$this->user = $user;
}
/**
@ -231,7 +227,6 @@ class BunqPrerequisites implements PrerequisitesInterface
*/
public function storePrerequisites(array $data): MessageBag
{
// TODO: Implement storePrerequisites() method.
throw new NotImplementedException;
return new MessageBag;
}
}

View File

@ -34,83 +34,83 @@ use Illuminate\Support\MessageBag;
*/
class FilePrerequisites implements PrerequisitesInterface
{
// /** @var User */
// private $user;
//
// /**
// * Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
// *
// * @return string
// */
// public function getView(): string
// {
// return '';
// }
//
// /**
// * Returns any values required for the prerequisites-view.
// *
// * @return array
// */
// public function getViewParameters(): array
// {
// return [];
// }
//
// /**
// * Returns if this import method has any special prerequisites such as config
// * variables or other things. The only thing we verify is the presence of the API key. Everything else
// * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
// *
// * True if prerequisites. False if not.
// *
// * @return bool
// *
// * @throws FireflyException
// */
// public function hasPrerequisites(): bool
// {
// if ($this->user->hasRole('demo')) {
// throw new FireflyException('Apologies, the demo user cannot import files.');
// }
//
// return false;
// }
//
// /**
// * Indicate if all prerequisites have been met.
// *
// * @return bool
// */
// public function isComplete(): bool
// {
// // has no prerequisites, so always return true.
// return true;
// }
//
// /**
// * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
// *
// * @param User $user
// */
// public function setUser(User $user): void
// {
// $this->user = $user;
//
// }
//
// /**
// * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
// * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
// *
// * @param Request $request
// *
// * @return MessageBag
// */
// public function storePrerequisites(Request $request): MessageBag
// {
// return new MessageBag;
// }
// /** @var User */
// private $user;
//
// /**
// * Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
// *
// * @return string
// */
// public function getView(): string
// {
// return '';
// }
//
// /**
// * Returns any values required for the prerequisites-view.
// *
// * @return array
// */
// public function getViewParameters(): array
// {
// return [];
// }
//
// /**
// * Returns if this import method has any special prerequisites such as config
// * variables or other things. The only thing we verify is the presence of the API key. Everything else
// * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
// *
// * True if prerequisites. False if not.
// *
// * @return bool
// *
// * @throws FireflyException
// */
// public function hasPrerequisites(): bool
// {
// if ($this->user->hasRole('demo')) {
// throw new FireflyException('Apologies, the demo user cannot import files.');
// }
//
// return false;
// }
//
// /**
// * Indicate if all prerequisites have been met.
// *
// * @return bool
// */
// public function isComplete(): bool
// {
// // has no prerequisites, so always return true.
// return true;
// }
//
// /**
// * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
// *
// * @param User $user
// */
// public function setUser(User $user): void
// {
// $this->user = $user;
//
// }
//
// /**
// * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
// * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
// *
// * @param Request $request
// *
// * @return MessageBag
// */
// public function storePrerequisites(Request $request): MessageBag
// {
// return new MessageBag;
// }
/**
* Returns view name that allows user to fill in prerequisites.
*
@ -118,8 +118,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/
public function getView(): string
{
// TODO: Implement getView() method.
throw new NotImplementedException;
return '';
}
/**
@ -129,8 +128,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/
public function getViewParameters(): array
{
// TODO: Implement getViewParameters() method.
throw new NotImplementedException;
return [];
}
/**
@ -140,8 +138,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/
public function isComplete(): bool
{
// TODO: Implement isComplete() method.
throw new NotImplementedException;
return true;
}
/**
@ -151,8 +148,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/
public function setUser(User $user): void
{
// TODO: Implement setUser() method.
throw new NotImplementedException;
}
/**
@ -166,7 +162,6 @@ class FilePrerequisites implements PrerequisitesInterface
*/
public function storePrerequisites(array $data): MessageBag
{
// TODO: Implement storePrerequisites() method.
throw new NotImplementedException;
return new MessageBag;
}
}

View File

@ -196,8 +196,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/
public function getView(): string
{
// TODO: Implement getView() method.
throw new NotImplementedException;
return '';
}
/**
@ -207,8 +206,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/
public function getViewParameters(): array
{
// TODO: Implement getViewParameters() method.
throw new NotImplementedException;
return [];
}
/**
@ -218,8 +216,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/
public function isComplete(): bool
{
// TODO: Implement isComplete() method.
throw new NotImplementedException;
return false;
}
/**
@ -229,8 +226,6 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/
public function setUser(User $user): void
{
// TODO: Implement setUser() method.
throw new NotImplementedException;
}
/**
@ -244,7 +239,6 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/
public function storePrerequisites(array $data): MessageBag
{
// TODO: Implement storePrerequisites() method.
throw new NotImplementedException;
return new MessageBag;
}
}

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace FireflyIII\Import\Storage;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace FireflyIII\Support\Import\Routine\Fake;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;