mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-30 21:30:14 +02:00
[phpcs] Add missing rules
- Do not add spaces after opening or before closing parenthesis // Wrong if( !is_null($var) ) { ... } // Right if(!is_null($var)) { ... } - Add space after closing parenthesis // Wrong if(true){ ... } // Right if(true) { ... } - Add body into new line - Close body in new line // Wrong if(true) { ... } // Right if(true) { ... } Notice: Spaces after keywords are not detected: // Wrong (not detected) // -> space after 'if' and missing space after 'else' if (true) { ... } else{ ... } // Right if(true) { ... } else { ... }
This commit is contained in:
@@ -43,9 +43,9 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
*/
|
||||
protected function setInputs(array $inputs, $queriedContext){
|
||||
// Import and assign all inputs to their context
|
||||
foreach($inputs as $name => $value){
|
||||
foreach(static::PARAMETERS as $context => $set){
|
||||
if(array_key_exists($name, static::PARAMETERS[$context])){
|
||||
foreach($inputs as $name => $value) {
|
||||
foreach(static::PARAMETERS as $context => $set) {
|
||||
if(array_key_exists($name, static::PARAMETERS[$context])) {
|
||||
$this->inputs[$context][$name]['value'] = $value;
|
||||
}
|
||||
}
|
||||
@@ -53,30 +53,30 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
|
||||
// Apply default values to missing data
|
||||
$contexts = array($queriedContext);
|
||||
if(array_key_exists('global', static::PARAMETERS)){
|
||||
if(array_key_exists('global', static::PARAMETERS)) {
|
||||
$contexts[] = 'global';
|
||||
}
|
||||
|
||||
foreach($contexts as $context){
|
||||
foreach(static::PARAMETERS[$context] as $name => $properties){
|
||||
if(isset($this->inputs[$context][$name]['value'])){
|
||||
foreach($contexts as $context) {
|
||||
foreach(static::PARAMETERS[$context] as $name => $properties) {
|
||||
if(isset($this->inputs[$context][$name]['value'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = isset($properties['type']) ? $properties['type'] : 'text';
|
||||
|
||||
switch($type){
|
||||
switch($type) {
|
||||
case 'checkbox':
|
||||
if(!isset($properties['defaultValue'])){
|
||||
if(!isset($properties['defaultValue'])) {
|
||||
$this->inputs[$context][$name]['value'] = false;
|
||||
} else {
|
||||
$this->inputs[$context][$name]['value'] = $properties['defaultValue'];
|
||||
}
|
||||
break;
|
||||
case 'list':
|
||||
if(!isset($properties['defaultValue'])){
|
||||
if(!isset($properties['defaultValue'])) {
|
||||
$firstItem = reset($properties['values']);
|
||||
if(is_array($firstItem)){
|
||||
if(is_array($firstItem)) {
|
||||
$firstItem = reset($firstItem);
|
||||
}
|
||||
$this->inputs[$context][$name]['value'] = $firstItem;
|
||||
@@ -85,7 +85,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(isset($properties['defaultValue'])){
|
||||
if(isset($properties['defaultValue'])) {
|
||||
$this->inputs[$context][$name]['value'] = $properties['defaultValue'];
|
||||
}
|
||||
break;
|
||||
@@ -94,11 +94,11 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
}
|
||||
|
||||
// Copy global parameter values to the guessed context
|
||||
if(array_key_exists('global', static::PARAMETERS)){
|
||||
foreach(static::PARAMETERS['global'] as $name => $properties){
|
||||
if(isset($inputs[$name])){
|
||||
if(array_key_exists('global', static::PARAMETERS)) {
|
||||
foreach(static::PARAMETERS['global'] as $name => $properties) {
|
||||
if(isset($inputs[$name])) {
|
||||
$value = $inputs[$name];
|
||||
} elseif(isset($properties['value'])){
|
||||
} elseif(isset($properties['value'])) {
|
||||
$value = $properties['value'];
|
||||
} else {
|
||||
continue;
|
||||
@@ -108,7 +108,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
}
|
||||
|
||||
// Only keep guessed context parameters values
|
||||
if(isset($this->inputs[$queriedContext])){
|
||||
if(isset($this->inputs[$queriedContext])) {
|
||||
$this->inputs = array($queriedContext => $this->inputs[$queriedContext]);
|
||||
} else {
|
||||
$this->inputs = array();
|
||||
@@ -125,15 +125,15 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
$queriedContexts = array();
|
||||
|
||||
// Detect matching context
|
||||
foreach(static::PARAMETERS as $context => $set){
|
||||
foreach(static::PARAMETERS as $context => $set) {
|
||||
$queriedContexts[$context] = null;
|
||||
|
||||
// Check if all parameters of the context are satisfied
|
||||
foreach($set as $id => $properties){
|
||||
if(isset($inputs[$id]) && !empty($inputs[$id])){
|
||||
foreach($set as $id => $properties) {
|
||||
if(isset($inputs[$id]) && !empty($inputs[$id])) {
|
||||
$queriedContexts[$context] = true;
|
||||
} elseif(isset($properties['required'])
|
||||
&& $properties['required'] === true){
|
||||
&& $properties['required'] === true) {
|
||||
$queriedContexts[$context] = false;
|
||||
break;
|
||||
}
|
||||
@@ -143,15 +143,15 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
|
||||
// Abort if one of the globally required parameters is not satisfied
|
||||
if(array_key_exists('global', static::PARAMETERS)
|
||||
&& $queriedContexts['global'] === false){
|
||||
&& $queriedContexts['global'] === false) {
|
||||
return null;
|
||||
}
|
||||
unset($queriedContexts['global']);
|
||||
|
||||
switch(array_sum($queriedContexts)){
|
||||
switch(array_sum($queriedContexts)) {
|
||||
case 0: // Found no match, is there a context without parameters?
|
||||
foreach($queriedContexts as $context => $queried){
|
||||
if(is_null($queried)){
|
||||
foreach($queriedContexts as $context => $queried) {
|
||||
if(is_null($queried)) {
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
@@ -168,13 +168,13 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
* @param array array with expected bridge paramters
|
||||
*/
|
||||
public function setDatas(array $inputs){
|
||||
if(!is_null($this->cache)){
|
||||
if(!is_null($this->cache)) {
|
||||
$time = $this->cache->getTime();
|
||||
if($time !== false
|
||||
&& (time() - static::CACHE_TIMEOUT < $time)
|
||||
&& (!defined('DEBUG') || DEBUG !== true)){
|
||||
&& (!defined('DEBUG') || DEBUG !== true)) {
|
||||
$cached = $this->cache->loadData();
|
||||
if(isset($cached['items']) && isset($cached['extraInfos'])){
|
||||
if(isset($cached['items']) && isset($cached['extraInfos'])) {
|
||||
$this->items = $cached['items'];
|
||||
$this->extraInfos = $cached['extraInfos'];
|
||||
return;
|
||||
@@ -182,27 +182,27 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
}
|
||||
}
|
||||
|
||||
if(empty(static::PARAMETERS)){
|
||||
if(!empty($inputs)){
|
||||
if(empty(static::PARAMETERS)) {
|
||||
if(!empty($inputs)) {
|
||||
returnClientError('Invalid parameters value(s)');
|
||||
}
|
||||
|
||||
$this->collectData();
|
||||
if(!is_null($this->cache)){
|
||||
if(!is_null($this->cache)) {
|
||||
$this->cache->saveData($this->getCachable());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!validateData($inputs, static::PARAMETERS)){
|
||||
if(!validateData($inputs, static::PARAMETERS)) {
|
||||
returnClientError('Invalid parameters value(s)');
|
||||
}
|
||||
|
||||
// Guess the paramter context from input data
|
||||
$this->queriedContext = $this->getQueriedContext($inputs);
|
||||
if(is_null($this->queriedContext)){
|
||||
if(is_null($this->queriedContext)) {
|
||||
returnClientError('Required parameter(s) missing');
|
||||
} elseif($this->queriedContext === false){
|
||||
} elseif($this->queriedContext === false) {
|
||||
returnClientError('Mixed context parameters');
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
|
||||
$this->collectData();
|
||||
|
||||
if(!is_null($this->cache)){
|
||||
if(!is_null($this->cache)) {
|
||||
$this->cache->saveData($this->getCachable());
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
* @return mixed Returns the input value or null if the input is not defined
|
||||
*/
|
||||
protected function getInput($input){
|
||||
if(!isset($this->inputs[$this->queriedContext][$input]['value'])){
|
||||
if(!isset($this->inputs[$this->queriedContext][$input]['value'])) {
|
||||
return null;
|
||||
}
|
||||
return $this->inputs[$this->queriedContext][$input]['value'];
|
||||
@@ -238,7 +238,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
|
||||
public function getName(){
|
||||
// Return cached name when bridge is using cached data
|
||||
if(isset($this->extraInfos)){
|
||||
if(isset($this->extraInfos)) {
|
||||
return $this->extraInfos['name'];
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||
|
||||
public function getURI(){
|
||||
// Return cached uri when bridge is using cached data
|
||||
if(isset($this->extraInfos)){
|
||||
if(isset($this->extraInfos)) {
|
||||
return $this->extraInfos['uri'];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user