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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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