mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup.
This commit is contained in:
@@ -31,20 +31,40 @@ trait AppendsLocationData
|
||||
/**
|
||||
* Abstract method.
|
||||
*
|
||||
* @param $key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function has($key);
|
||||
|
||||
/**
|
||||
* Abstract method.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function method();
|
||||
|
||||
/**
|
||||
* Abstract method.
|
||||
*
|
||||
* @param mixed ...$patterns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function routeIs(...$patterns);
|
||||
|
||||
/**
|
||||
* Abstract method stolen from "InteractsWithInput".
|
||||
*
|
||||
* @param null $key
|
||||
* @param bool $default
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*/
|
||||
abstract public function boolean($key = null, $default = false);
|
||||
|
||||
/**
|
||||
* Read the submitted Request data and add new or updated Location data to the array.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @param string|null $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function appendLocationData(array $data, ?string $prefix): array
|
||||
{
|
||||
@@ -97,12 +117,6 @@ trait AppendsLocationData
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $prefix
|
||||
* @param string $key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLocationKey(?string $prefix, string $key): string
|
||||
{
|
||||
if (null === $prefix) {
|
||||
@@ -112,11 +126,6 @@ trait AppendsLocationData
|
||||
return sprintf('%s_%s', $prefix, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $prefix
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isValidPost(?string $prefix): bool
|
||||
{
|
||||
app('log')->debug('Now in isValidPost()');
|
||||
@@ -155,38 +164,6 @@ trait AppendsLocationData
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract method.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function method();
|
||||
|
||||
/**
|
||||
* Abstract method.
|
||||
*
|
||||
* @param mixed ...$patterns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function routeIs(...$patterns);
|
||||
|
||||
/**
|
||||
* Abstract method stolen from "InteractsWithInput".
|
||||
*
|
||||
* @param null $key
|
||||
* @param bool $default
|
||||
*
|
||||
* @return mixed
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*/
|
||||
abstract public function boolean($key = null, $default = false);
|
||||
|
||||
/**
|
||||
* @param string|null $prefix
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isValidPUT(?string $prefix): bool
|
||||
{
|
||||
$longitudeKey = $this->getLocationKey($prefix, 'longitude');
|
||||
@@ -227,11 +204,6 @@ trait AppendsLocationData
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $prefix
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isValidEmptyPUT(?string $prefix): bool
|
||||
{
|
||||
$longitudeKey = $this->getLocationKey($prefix, 'longitude');
|
||||
@@ -239,9 +211,9 @@ trait AppendsLocationData
|
||||
$zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level');
|
||||
|
||||
return (
|
||||
null === $this->get($longitudeKey)
|
||||
&& null === $this->get($latitudeKey)
|
||||
&& null === $this->get($zoomLevelKey))
|
||||
null === $this->get($longitudeKey)
|
||||
&& null === $this->get($latitudeKey)
|
||||
&& null === $this->get($zoomLevelKey))
|
||||
&& (
|
||||
'PUT' === $this->method()
|
||||
|| ('POST' === $this->method() && $this->routeIs('*.update'))
|
||||
|
Reference in New Issue
Block a user