Showing 30 of 38 total issues
File Image.php
has 542 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace JohnVanOrange\API;
use Imagick;
class Image extends Base {
Function get
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function get($image, $sid = NULL, $session = NULL, $brazzify = FALSE) {
$setting = new Setting;
$current = $this->user->current($sid);
//Get image data
$query = new \Peyote\Select('images');
- 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 get
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get($image, $sid = NULL, $session = NULL, $brazzify = FALSE) {
$setting = new Setting;
$current = $this->user->current($sid);
//Get image data
$query = new \Peyote\Select('images');
Image
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Image extends Base {
private $user;
public function __construct() {
File User.php
has 280 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace JohnVanOrange\API;
class User extends Base {
Method processAdd
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processAdd($path, $c_link=NULL, $sid = NULL) {
$setting = new Setting;
$web_root = $setting->get('web_root');
$info = getimagesize($path);
if (!$info) {
Method call
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function call($method, $params=[]) {
$result = explode('/',$method);
$class = $result[0];
$method = $result[1];
Method get
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get($uid) {
$query = new \Peyote\Select('media');
$query->columns('media.uid',
'media.file',
'media.format',
Method changepw
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function changepw($password, $auth, $type = 'sid') {
if (!$password) throw new \Exception('Password is blank');
switch ($type) {
case 'pwreset':
$query = new \Peyote\Select('resources');
Method add
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add($name, $image, $sid = NULL) {
$setting = new Setting;
if ($setting->get('tags_need_auth')) {
$user = new User;
if ( !$user->isLoggedIn($sid) ) throw new \Exception('Must be logged in to add a tag', 1032);
Function call
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function call($method, $params=[]) {
$result = explode('/',$method);
$class = $result[0];
$method = $result[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
Method current
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function current($sid=NULL) {
if (!isset($sid)) $sid = $this->getSID();
$query = new \Peyote\Select('sessions');
$query->columns('user_id')
->where('sid', '=', $sid)
Method remove
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function remove($image, $sid=NULL) {
if (!$this->canRemove($image, $sid)) throw new \JohnVanOrange\Core\Exception\NotAllowed('You don\'t have permission to remove this image', 401);
$data = $this->get($image, $sid);
//clean up resources
$query = new \Peyote\Delete('resources');
Method requestPwReset
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function requestPwReset($username) {
$setting = new Setting;
$site_name = $setting->get('site_name');
$user = $this->get($username, 'username');
$uid = $this->getSecureID();
Method get
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get($value, $search_by='image') {
$setting = new Setting;
if (!$value) throw new \JohnVanOrange\Core\Exception\NotFound('Tag value not set', 404);
switch ($search_by) {
case 'name':
Function saved
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function saved($username = NULL, $sid=NULL) {
$current = $this->current($sid);
if ($username) {
$user = $this->get($username, 'username');
if ($current['id'] != $user['id']) throw new \Exception('This users saved images are not publicly shared');
- 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 uploaded
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function uploaded($username = NULL, $sid=NULL) {
$current = $this->current($sid);
if ($username) {
$user = $this->get($username, 'username');
if ($current['id'] != $user['id']) throw new \Exception('This users uploaded images are not publicly shared');
- 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 add
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function add($name, $image, $sid = NULL) {
$setting = new Setting;
if ($setting->get('tags_need_auth')) {
$user = new User;
if ( !$user->isLoggedIn($sid) ) throw new \Exception('Must be logged in to add a tag', 1032);
- 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 __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($options = NULL) {
parent::__construct('images');
$this->options = $options;
Function current
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function current($sid=NULL) {
if (!isset($sid)) $sid = $this->getSID();
$query = new \Peyote\Select('sessions');
$query->columns('user_id')
->where('sid', '=', $sid)
- 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"