File UsersFunctions.php
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* Copyright 2018 Jérôme Gasperi
*
Method formatUserProfile
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function formatUserProfile($rawProfile)
{
// Empty profile
$profile = array();
Function updateUserProfile
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function updateUserProfile($profile, $storageInfo)
{
if (!is_array($profile) || !isset($profile['email'])) {
RestoLogUtil::httpError(400);
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function formatPartialUserProfile
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function formatPartialUserProfile($rawProfile)
{
$profile = array(
'id' => $rawProfile['id'],
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function formatUserProfile
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function formatUserProfile($rawProfile)
{
// Empty profile
$profile = array();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method updateUserProfile
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateUserProfile($profile, $storageInfo)
{
if (!is_array($profile) || !isset($profile['email'])) {
RestoLogUtil::httpError(400);
}
Method formatPartialUserProfile
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function formatPartialUserProfile($rawProfile)
{
$profile = array(
'id' => $rawProfile['id'],
Method storeUserProfile
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function storeUserProfile($profile, $storageInfo)
{
if (!is_array($profile) || !isset($profile['email'])) {
RestoLogUtil::httpError(400, 'Cannot save user profile - invalid user identifier');
}
Method getUsersProfiles
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUsersProfiles($params, $userid)
{
// Only returns activated profiles
$where = array(
'activated=1'
Function getPicture
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getPicture($profile, $storageInfo = null)
{
// Create picture url from email
if (!isset($profile['picture'])) {
return 'https://robohash.org/' . md5($profile['email']) . '?gravatar=hashed&bgset=any&size=400x400';
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getUsersProfiles
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getUsersProfiles($params, $userid)
{
// Only returns activated profiles
$where = array(
'activated=1'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getUserProfile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getUserProfile($fieldName, $fieldValue, $params = array())
{
// Add followed and followme booleans
$fields = $this->userFields;
if (isset($params['from'])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function storeUserProfile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function storeUserProfile($profile, $storageInfo)
{
if (!is_array($profile) || !isset($profile['email'])) {
RestoLogUtil::httpError(400, 'Cannot save user profile - invalid user identifier');
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"