File Subsonic_Xml_Data.php
has 1182 lines of code (exceeds 500 allowed). Consider refactoring. Open
<?php
declare(strict_types=0);
/**
Subsonic_Xml_Data
has 88 functions (exceeds 20 allowed). Consider refactoring. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
The class Subsonic_Xml_Data has 55 public methods. Consider refactoring Subsonic_Xml_Data to keep number of public methods under 10. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Subsonic_Xml_Data has 85 non-getter- and setter-methods. Consider refactoring Subsonic_Xml_Data to keep number of methods under 25. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class Subsonic_Xml_Data has an overall complexity of 291 which is very high. The configured complexity threshold is 50. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Exclude checks
Function addSong
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
{
$song = new Song($song_id);
if ($song->isNew()) {
return $xml;
- 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 addIndex
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private static function addIndex($xml, $artists): void
{
$xlastcat = null;
$sharpartists = array();
$xlastletter = '';
- 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 addArtist
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function addArtist($xml, $artist, $extra = false, $albums = false, $albumsSet = false): void
{
if ($artist->isNew()) {
return;
}
- 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 addPlaylists
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function addPlaylists($xml, $user_id, $playlists, $smartplaylists = array(), $hide_dupe_searches = false): void
{
$playlist_names = array();
$xplaylists = self::addChildToResultXml($xml, 'playlists');
foreach ($playlists as $plist_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 addAlbum
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function addAlbum($xml, $album, $songs = false, $elementName = "album"): void
{
if ($album->isNew()) {
return;
}
- 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
The class Subsonic_Xml_Data has 56 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Function addShare
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function addShare($xml, $share): void
{
$xshare = self::addChildToResultXml($xml, 'share');
$xshare->addAttribute('id', (string)$share->id);
$xshare->addAttribute('url', (string)$share->public_url);
- 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 addError
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function addError($code, $function): SimpleXMLElement
{
$xml = self::_createFailedResponse($function);
/** @var SimpleXMLElement $xerr */
$xerr = self::addChildToResultXml($xml, 'error');
- 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 addVideo
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function addVideo($xml, $video, $elementName = 'video'): void
{
$sub_id = (string)self::_getVideoId($video->id);
$xvideo = self::addChildToResultXml($xml, htmlspecialchars($elementName));
$xvideo->addAttribute('id', $sub_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 _getAmpacheType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function _getAmpacheType($object_id): string
{
if (self::_isArtist($object_id)) {
return "artist";
} elseif (self::_isAlbum($object_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 addPodcasts
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function addPodcasts($xml, $podcasts, $includeEpisodes = true): void
{
$podcastRepository = self::getPodcastRepository();
$xpodcasts = self::addChildToResultXml($xml, 'podcasts');
- 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 addPlaylists
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function addPlaylists($xml, $user_id, $playlists, $smartplaylists = array(), $hide_dupe_searches = false): void
Method addArtist
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function addArtist($xml, $artist, $extra = false, $albums = false, $albumsSet = false): void
Function _setIfStarred
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private static function _setIfStarred($xml, $objectType, $object_id): void
{
if (InterfaceImplementationChecker::is_library_item($objectType)) {
if (AmpConfig::get('ratings')) {
$starred = new Userflag($object_id, $objectType);
- 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
Avoid too many return
statements within this method. Open
return "video";
Avoid too many return
statements within this method. Open
return "playlist";
Avoid too many return
statements within this method. Open
return "podcast";
Avoid too many return
statements within this method. Open
return "podcast_episode";
Avoid too many return
statements within this method. Open
return "";
Function addLyrics
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function addLyrics($xml, $artist, $title, $song_id): void
{
$song = new Song($song_id);
$song->fill_ext_info('lyrics');
$lyrics = $song->get_lyrics();
- 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
The method addAlbum() has an NPath complexity of 2304. The configured NPath complexity threshold is 200. Open
public static function addAlbum($xml, $album, $songs = false, $elementName = "album"): void
{
if ($album->isNew()) {
return;
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method addSong() has an NPath complexity of 11522. The configured NPath complexity threshold is 200. Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
{
$song = new Song($song_id);
if ($song->isNew()) {
return $xml;
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method addUser() has an NPath complexity of 256. The configured NPath complexity threshold is 200. Open
public static function addUser($xml, $user): void
{
$xuser = self::addChildToResultXml($xml, 'user');
$xuser->addAttribute('username', (string)$user->username);
$xuser->addAttribute('email', (string)$user->email);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The class Subsonic_Xml_Data has 1770 lines of code. Current threshold is 1000. Avoid really long classes. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Exclude checks
The method addIndex() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
private static function addIndex($xml, $artists): void
{
$xlastcat = null;
$sharpartists = array();
$xlastletter = '';
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method addArtist() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function addArtist($xml, $artist, $extra = false, $albums = false, $albumsSet = false): void
{
if ($artist->isNew()) {
return;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method addVideo() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
private static function addVideo($xml, $video, $elementName = 'video'): void
{
$sub_id = (string)self::_getVideoId($video->id);
$xvideo = self::addChildToResultXml($xml, htmlspecialchars($elementName));
$xvideo->addAttribute('id', $sub_id);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method addUser() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function addUser($xml, $user): void
{
$xuser = self::addChildToResultXml($xml, 'user');
$xuser->addAttribute('username', (string)$user->username);
$xuser->addAttribute('email', (string)$user->email);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method addAlbum() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. Open
public static function addAlbum($xml, $album, $songs = false, $elementName = "album"): void
{
if ($album->isNew()) {
return;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method addSong() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
{
$song = new Song($song_id);
if ($song->isNew()) {
return $xml;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method addPlaylists() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function addPlaylists($xml, $user_id, $playlists, $smartplaylists = array(), $hide_dupe_searches = false): void
{
$playlist_names = array();
$xplaylists = self::addChildToResultXml($xml, 'playlists');
foreach ($playlists as $plist_id) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Reduce the number of returns of this function 4, down to the maximum allowed 3. Open
public static function _getAmpacheObject($object_id)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 32 to the 15 allowed. Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Reduce the number of returns of this function 9, down to the maximum allowed 3. Open
public static function _getAmpacheType($object_id): string
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Class "Subsonic_Xml_Data" has 88 methods, which is greater than 20 authorized. Split it into smaller classes. Open
class Subsonic_Xml_Data
- Read upRead up
- Exclude checks
A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.
Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
private static function addIndex($xml, $artists): void
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
The class Subsonic_Xml_Data has a coupling between objects value of 29. Consider to reduce the number of dependencies under 13. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
The method addIndex uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (!preg_match("/^[A-W]$/", $letter)) {
$sharpartists[] = $artist;
continue;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method addArtist uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$xartist->addAttribute('albumCount', (string)count($allalbums));
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method addDirectory_Album uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$xdir->addAttribute('parent', (string)$album->catalog);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method addPlaylist_Search uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$xplaylist->addAttribute('songCount', (string)$search->last_count);
$xplaylist->addAttribute('duration', (string)$search->last_duration);
$xplaylist->addAttribute('coverArt', $sub_id);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method addMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$xbookmark->addAttribute('username', (string)$user->username);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Define a constant instead of duplicating this literal "changed" 4 times. Open
$xplaylist->addAttribute('changed', date("c", (int)$playlist->last_update));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "video" 6 times. Open
private static function addVideo($xml, $video, $elementName = 'video'): void
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "false" 16 times. Open
$xsong->addAttribute('isDir', 'false');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "username" 7 times. Open
$xplayqueue->addAttribute('username', (string)$username);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "suffix" 3 times. Open
$xsong->addAttribute('suffix', (string)$song->type);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "duration" 7 times. Open
$xalbum->addAttribute('duration', (string) $album->total_duration);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "catalog_id" 4 times. Open
if (array_key_exists('catalog_id', $child)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "genre" 5 times. Open
$xalbum->addAttribute('genre', (string)$tag['name']);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "entry" 11 times. Open
self::addSong($xplaylist, $song_id, "entry");
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "directory" 3 times. Open
$xdir = self::addChildToResultXml($xml, 'directory');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "object_id" 4 times. Open
self::addSong($xplaylist, (int)$item['object_id'], "entry");
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Merge this if statement with the enclosing one. Open
if (AmpConfig::get('ratings')) {
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if (condition1) { if (condition2) { ... } }
Compliant Solution
if (condition1 && condition2) { ... }
Define a constant instead of duplicating this literal "child" 3 times. Open
$xchild = self::addChildToResultXml($xml, 'child');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "isDir" 5 times. Open
$xchild->addAttribute('isDir', 'true');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "artist" 12 times. Open
$xartist = self::addChildToResultXml($xml, 'artist');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "contentType" 3 times. Open
$xsong->addAttribute('contentType', (string)$song->mime);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "f_name" 4 times. Open
$xchild->addAttribute('title', (string)self::_checkName($child['f_name']));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "status" 3 times. Open
$xchannel->addAttribute('status', 'completed');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "parent" 7 times. Open
$xchild->addAttribute('parent', $child['catalog_id']);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "title" 7 times. Open
$xchild->addAttribute('title', (string)self::_checkName($child['f_name']));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "description" 3 times. Open
$xshare->addAttribute('description', (string)$share->description);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Merge this if statement with the enclosing one. Open
if (is_numeric($name)) {
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if (condition1) { if (condition2) { ... } }
Compliant Solution
if (condition1 && condition2) { ... }
Define a constant instead of duplicating this literal "has_art" 4 times. Open
if (array_key_exists('has_art', $child) && !empty($child['has_art'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "podcast_episode" 4 times. Open
} elseif ($bookmark->object_type == "podcast_episode") {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "created" 5 times. Open
$xalbum->addAttribute('created', date("c", (int)$album->addition_time));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "coverArt" 11 times. Open
$xartist->addAttribute('coverArt', 'ar-' . $sub_id);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "songCount" 5 times. Open
$xalbum->addAttribute('songCount', (string) $album->song_count);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "position" 3 times. Open
$xplayqueue->addAttribute('position', (string)($current['current_time'] * 1000));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "playlist" 4 times. Open
$xplaylist = self::addChildToResultXml($xml, 'playlist');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "album" 12 times. Open
public static function addAlbum($xml, $album, $songs = false, $elementName = "album"): void
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "albumCount" 4 times. Open
$xartist->addAttribute('albumCount', (string)$artist->album_count);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Remove this commented out code. Open
//$xalbum->addAttribute('discNumber', (string)$album->disk);
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Remove this commented out code. Open
// $artist = new Artist($song->artist);
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Remove this commented out code. Open
//$xartist->addChild('lastFmUrl', "");
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Define a constant instead of duplicating this literal "track" 4 times. Open
$xsong->addAttribute('track', (string)$song->track);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Remove this commented out code. Open
//$xartist->addChild('lastFmUrl', "");
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Add a "case default" clause to this "switch" statement. Open
switch ($dirType) {
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Remove this commented out code. Open
//$xsong->addAttribute('created', );
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Add a "case default" clause to this "switch" statement. Open
switch ($code) {
- Read upRead up
- Exclude checks
The requirement for a final case default
clause is defensive programming. The clause should either take appropriate action, or contain
a suitable comment as to why no action is taken. Even when the switch
covers all current values of an enum
, a default case
should still be used because there is no guarantee that the enum
won't be extended.
Noncompliant Code Example
switch ($param) { //missing default clause case 0: do_something(); break; case 1: do_something_else(); break; } switch ($param) { default: // default clause should be the last one error(); break; case 0: do_something(); break; case 1: do_something_else(); break; }
Compliant Solution
switch ($param) { case 0: do_something(); break; case 1: do_something_else(); break; default: error(); break; }
See
- MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
- MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
- MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
- MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
- MISRA C:2012, 16.1 - All switch statements shall be well-formed
- MISRA C:2012, 16.4 - Every switch statement shall have a default label
- MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
- MITRE, CWE-478 - Missing Default Case in Switch Statement
- CERT, MSC01-C. - Strive for logical completeness
- CERT, MSC01-CPP. - Strive for logical completeness
Avoid unused local variables such as '$podcastRepository'. Open
$podcastRepository = self::getPodcastRepository();
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO This can be random play, democratic, podcasts, etc. not just songs
- Exclude checks
TODO found Open
// TODO addChild || use addChildArray
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
// TODO addChild || use addChildArray
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
TODO found Open
$xjbox->addAttribute('position', '0'); // TODO Not supported
- Exclude checks
TODO found Open
// TODO addEntry
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('name', (string)self::_checkName($artist->get_fullname()));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addAlbumList($xml, $albums): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addAlbum($xml, $album, $songs = false, $elementName = "album"): void
- Exclude checks
Call to method has_art
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->has_art()) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xindexes->addAttribute('lastModified', number_format($lastModified * 1000, 0, '.', ''));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('albumCount', (string)count($allalbums));
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Parameter $album
has undeclared type \Ampache\Repository\Model\Album
Open
public static function addAlbum($xml, $album, $songs = false, $elementName = "album"): void
- Exclude checks
Call to method get_user_rating
from undeclared class \Ampache\Repository\Model\Rating
Open
$user_rating = ($rating->get_user_rating() ?? 0);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Artist
Open
if ($artist->isNew()) {
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Artist
Open
$allalbums = static::getAlbumRepository()->getAlbumByArtist($artist->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchild->addAttribute('id', $sub_id);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->isNew()) {
- Exclude checks
Reference to instance property total_count
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('playCount', (string)$album->total_count);
- Exclude checks
Reference to instance property year
from undeclared class \Ampache\Repository\Model\Album
Open
: $album->year;
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Album
Open
$tag_values = array_values($album->tags);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Album
Open
$album->format();
- Exclude checks
Reference to instance property song_count
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('songCount', (string) $album->song_count);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('artistId', (string)self::_getArtistId($album->album_artist));
- Exclude checks
Call to method get_artist_fullname
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('artist', (string) self::_checkName($album->get_artist_fullname()));
- Exclude checks
Reference to instance property title
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('title', (string)self::_checkName($song->title));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('isDir', 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('albumId', $subParent);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addLicense($xml): void
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('parent', (string)self::_getArtistId($album->album_artist));
- Exclude checks
Reference to instance property total_duration
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('duration', (string) $album->total_duration);
- Exclude checks
Reference to instance property tags
from undeclared class \Ampache\Repository\Model\Album
Open
if (count($album->tags) > 0) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('genre', (string)$tag['name']);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Rating
Open
$rating = new Rating($album->id, "album");
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song($song_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('title', (string)self::_checkName($song->title));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('isVideo', 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xerr->addAttribute('message', (string)$message);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addMusicFolders($xml, $catalogs): void
- Exclude checks
Return type of addSubsonicResponse()
is undeclared type \SimpleXMLElement
Open
public static function addSubsonicResponse($function): SimpleXMLElement
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xml->addAttribute('ignoredArticles', (string)$ignoredArticles);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('id', $sub_id);
- Exclude checks
Call to deprecated function \Ampache\Module\Api\Subsonic_Xml_Data::getAlbumRepository()
defined at /code/src/Module/Api/Subsonic_Xml_Data.php:1817
Open
$allalbums = static::getAlbumRepository()->getAlbumByArtist($artist->id);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addChildArray($xml, $child): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('playCount', (string)$album->total_count);
- Exclude checks
Return type of addSong()
is undeclared type \SimpleXMLElement
Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('albumCount', (string)$artist['album_count']);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Song
Open
if ($song->isNew()) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('isDir', 'true');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
$rating = new Rating($album->id, "album");
- Exclude checks
Call to deprecated function \Ampache\Module\Api\Subsonic_Xml_Data::getAlbumRepository()
defined at /code/src/Module/Api/Subsonic_Xml_Data.php:1817
Open
$media_ids = static::getAlbumRepository()->getSongs($album->id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xerr->addAttribute('code', (string)$code);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addIgnoredArticles($xml): void
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Artist
Open
$sub_id = (string)self::_getArtistId($artist->id);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Artist
Open
self::_setIfStarred($xartist, 'artist', $artist->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchild->addAttribute('isDir', 'true');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('id', $sub_id);
- Exclude checks
Reference to instance property original_year
from undeclared class \Ampache\Repository\Model\Album
Open
? $album->original_year
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xlic->addAttribute('valid', 'true');
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addArtist($xml, $artist, $extra = false, $albums = false, $albumsSet = false): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addArtistArray($xml, $artist): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('name', (string)self::_checkName($artist['f_name']));
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Album
Open
$f_name = (string)self::_checkName($album->get_fullname());
- Exclude checks
Reference to instance property addition_time
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('created', date("c", (int)$album->addition_time));
- Exclude checks
Return type of addError()
is undeclared type \SimpleXMLElement
Open
public static function addError($code, $function): SimpleXMLElement
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xlic->addAttribute('email', 'webmaster@ampache.org');
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Artist
Open
$xartist->addAttribute('name', (string)self::_checkName($artist->get_fullname()));
- Exclude checks
Call to method create_from_id
from undeclared class \Ampache\Repository\Model\Catalog
Open
$catalog = Catalog::create_from_id($folder_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('albumCount', (string)$artist->album_count);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addIndex($xml, $artists): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchild->addAttribute('title', (string)self::_checkName($child['f_name']));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('name', $f_name);
- Exclude checks
Parameter $artist
has undeclared type \Ampache\Repository\Model\Artist
Open
public static function addArtist($xml, $artist, $extra = false, $albums = false, $albumsSet = false): void
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
$xalbum->addAttribute('artistId', (string)self::_getArtistId($album->album_artist));
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('averageRating', (string)$avg_rating);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('created', date("c", (int)$album->addition_time));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('parent', $subParent);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xlastcat->addAttribute('name', (string)$xlastletter);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist->format();
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchild->addAttribute('parent', $child['catalog_id']);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('coverArt', 'ar-' . $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('coverArt', 'al-' . $sub_id);
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->album_artist) {
- Exclude checks
Reference to instance property original_year
from undeclared class \Ampache\Repository\Model\Album
Open
$year = ($original_year && $album->original_year)
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('year', (string)$year);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
$media_ids = static::getAlbumRepository()->getSongs($album->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('id', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('type', 'music');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchild->addAttribute('artist', (string)self::_checkName($child['f_name']));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchild->addAttribute('coverArt', 'ar-' . $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('title', $f_name);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
self::_setIfStarred($xalbum, 'album', $album->id);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Song
Open
$sub_id = (string)self::_getSongId($song->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xfolder->addAttribute('id', (string)$folder_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xfolder->addAttribute('name', (string)$catalog->name);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsharpcat->addAttribute('name', '#');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('coverArt', 'ar-' . $sub_id);
- Exclude checks
Reference to instance property album_count
from undeclared class \Ampache\Repository\Model\Artist
Open
$xartist->addAttribute('albumCount', (string)$artist->album_count);
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->album_artist) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('parent', (string)self::_getArtistId($album->album_artist));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addIndexes($xml, $artists, $lastModified = 0): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xartist->addAttribute('id', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('userRating', (string)ceil($user_rating));
- Exclude checks
Call to method get_average_rating
from undeclared class \Ampache\Repository\Model\Rating
Open
$avg_rating = $rating->get_average_rating();
- Exclude checks
Reference to instance property enabled
from undeclared class \Ampache\Repository\Model\Song
Open
if ($song->enabled) {
- Exclude checks
Reference to instance property album
from undeclared class \Ampache\Repository\Model\Song
Open
$subParent = (string)self::_getAlbumId($song->album);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addArtists($xml, $artists): void
- Exclude checks
Call to method has_art
from undeclared class \Ampache\Repository\Model\Artist
Open
if ($artist->has_art()) {
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addAlbumList2($xml, $albums): void
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
$sub_id = (string)self::_getAlbumId($album->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('album', $f_name);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('songCount', (string) $album->song_count);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('duration', (string) $album->total_duration);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xalbum->addAttribute('artist', (string) self::_checkName($album->get_artist_fullname()));
- Exclude checks
Reference to instance property year
from undeclared class \Ampache\Repository\Model\Song
Open
if ($song->year > 0) {
- Exclude checks
Call to method get_cache_path
from undeclared class \Ampache\Repository\Model\Catalog
Open
$file_target = Catalog::get_cache_path($song->getId(), $song->getCatalogId(), $cache_path, $cache_target);
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('size', (string)$video->size);
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->last_update
Open
$xplaylist->addAttribute('changed', date("c", (int)$playlist->last_update));
- Exclude checks
Call to method get_id_array
from undeclared class \Ampache\Repository\Model\Artist
Open
$data = Artist::get_id_array($artist_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('id', (string)$catalog_id);
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('suffix', (string)$video->type);
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\Search
Open
$playlist->isNew() ||
- Exclude checks
Call to method get_album_fullname
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('album', (string)self::_checkName($song->get_album_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('artist', (string)self::_checkName($song->get_artist_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('discNumber', (string)$disk);
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
if ($album->album_artist) {
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addPlaylist($xml, $playlist, $songs = false): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('id', $sub_id);
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('suffix', (string)$song->type);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('contentType', (string)$song->mime);
- Exclude checks
Reference to instance property catalog
from undeclared class \Ampache\Repository\Model\Album
Open
$xdir->addAttribute('parent', (string)$album->catalog);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xgenre->addAttribute('albumCount', (string)($counts['album'] ?? 0));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addVideos($xml, $videos): void
- Exclude checks
Parameter $video
has undeclared type \Ampache\Repository\Model\Video
Open
private static function addVideo($xml, $video, $elementName = 'video'): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('duration', (string)$video->time);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('transcodedSuffix', (string)$transcode_type);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideoinfo->addAttribute('id', (string)$video_id);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Song
Open
self::_setIfStarred($xsong, 'song', $song->id);
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('size', (string)$song->size);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Reference to instance property album_artist
from undeclared class \Ampache\Repository\Model\Album
Open
$xdir->addAttribute('parent', (string)self::_getArtistId($album->album_artist));
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
self::_setIfStarred($xdir, 'album', $album->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xgenre->addAttribute('songCount', (string)($counts['song'] ?? 0));
- Exclude checks
Call to method has_art
from undeclared class \Ampache\Repository\Model\Video
Open
if ($video->has_art()) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('coverArt', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('genre', (string)$tags[0]['name']);
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->id
Open
$sub_id = (string)self::_getPlaylistId($playlist->id);
- Exclude checks
Call to undeclared method \Ampache\Repository\Model\Playlist::has_art
Open
if ($playlist->has_art()) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('coverArt', $sub_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addPlaylist_Search($xml, $search, $songs = false): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('album', (string)self::_checkName($song->get_album_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('coverArt', $art_id);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Song
Open
$rating = new Rating($song->id, "song");
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('userRating', (string)ceil($user_rating));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('averageRating', (string)$avg_rating);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('transcodedSuffix', $transcode_type);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Video
Open
$sub_id = (string)self::_getVideoId($video->id);
- Exclude checks
Call to method getFileName
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('title', $video->getFileName());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('isDir', 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('contentType', (string)$video->mime);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('transcodedContentType', Video::type_to_mime($transcode_type));
- Exclude checks
Parameter $playlist
has undeclared type \Ampache\Repository\Model\Search
Open
public static function addPlaylist($xml, $playlist, $songs = false): void
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->type
Open
$xplaylist->addAttribute('public', ($playlist->type != "private") ? "true" : "false");
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('id', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('genre', (string)$tags[0]['name']);
- Exclude checks
Call to deprecated function \Ampache\Module\Api\Subsonic_Xml_Data::getAlbumRepository()
defined at /code/src/Module/Api/Subsonic_Xml_Data.php:1817
Open
$allalbums = static::getAlbumRepository()->getAlbumByArtist($artist_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('name', (string)self::_checkName($album->get_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('suffix', (string)$video->type);
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->user
Open
if ($hide_dupe_searches && $playlist->user == $user_id) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('changed', date("c", (int)$playlist->last_update));
- Exclude checks
Parameter $search
has undeclared type \Ampache\Repository\Model\Search
Open
private static function addPlaylist_Search($xml, $search, $songs = false): void
- Exclude checks
Reference to instance property time
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('duration', (string)$song->time);
- Exclude checks
Call to method get_artist_fullname
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('artist', (string)self::_checkName($song->get_artist_fullname()));
- Exclude checks
Reference to instance property bitrate
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('bitRate', (string)((int)($song->bitrate / 1024)));
- Exclude checks
Reference to instance property file
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('path', (string)$song->file);
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Song
Open
: Stream::get_transcode_format($song->type, null, 'api');
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addDirectory_Album($xml, $album_id): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addDirectory_Artist($xml, $sub_id): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album(self::_getAmpacheId($album_id));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('parent', (string)$album->catalog);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Album
Open
$media_ids = static::getAlbumRepository()->getSongs($album->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('isVideo', 'true');
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Album
Open
$album->format();
- Exclude checks
Call to deprecated function \Ampache\Module\Api\Subsonic_Xml_Data::getAlbumRepository()
defined at /code/src/Module/Api/Subsonic_Xml_Data.php:1817
Open
$media_ids = static::getAlbumRepository()->getSongs($album->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('size', (string)$video->size);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Tag
Open
$otag = new Tag($tag['id']);
- Exclude checks
Reference to instance property time
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('duration', (string)$video->time);
- Exclude checks
Reference to instance property file
from undeclared class \Ampache\Repository\Model\Video
Open
$path = basename($video->file);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('name', (string)$catalog->name);
- Exclude checks
Reference to instance property year
from undeclared class \Ampache\Repository\Model\Video
Open
if (isset($video->year) && $video->year > 0) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('year', (string)$video->year);
- Exclude checks
Call to method type_to_mime
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('transcodedContentType', Video::type_to_mime($transcode_type));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('path', (string)$path);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('type', 'video');
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addPlaylists($xml, $user_id, $playlists, $smartplaylists = array(), $hide_dupe_searches = false): void
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Search
Open
$sub_id = (string) self::_getSmartPlaylistId($search->id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addPlaylist_Playlist($xml, $playlist, $songs = false): void
- Exclude checks
Call to undeclared method \Ampache\Repository\Model\Playlist::get_fullname
Open
$xplaylist->addAttribute('name', (string)self::_checkName($playlist->get_fullname()));
- Exclude checks
Call to method has_art
from undeclared class \Ampache\Repository\Model\Song
Open
if ($song->has_art()) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('bitRate', (string)((int)($song->bitrate / 1024)));
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Rating
Open
$rating = new Rating($song->id, "song");
- Exclude checks
Call to method get_user_rating
from undeclared class \Ampache\Repository\Model\Rating
Open
$user_rating = ($rating->get_user_rating() ?? 0);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('suffix', (string)$song->type);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('artistId', ($song->artist) ? (string)self::_getArtistId($song->artist) : '');
- Exclude checks
Call to method getId
from undeclared class \Ampache\Repository\Model\Song
Open
$file_target = Catalog::get_cache_path($song->getId(), $song->getCatalogId(), $cache_path, $cache_target);
- Exclude checks
Reference to instance property track
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('track', (string)$song->track);
- Exclude checks
Reference to instance property year
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('year', (string)$song->year);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('size', (string)$song->size);
- Exclude checks
Call to method get_artist_arrays
from undeclared class \Ampache\Repository\Model\Catalog
Open
$allartists = Catalog::get_artist_arrays(array($catalog_id));
- Exclude checks
Call to method get_average_rating
from undeclared class \Ampache\Repository\Model\Rating
Open
$avg_rating = $rating->get_average_rating();
- Exclude checks
Call to method count
from undeclared class \Ampache\Repository\Model\Tag
Open
$counts = $otag->count();
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('id', (string)$album_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('track', (string)$song->track);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('parent', (string)self::_getArtistId($album->album_artist));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('year', (string)$song->year);
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Album
Open
$xdir->addAttribute('name', (string)self::_checkName($album->get_fullname()));
- Exclude checks
Reference to instance property name
from undeclared class \Ampache\Repository\Model\Tag
Open
$xgenre = self::addChildToResultXml($xgenres, 'genre', htmlspecialchars((string)$otag->name));
- Exclude checks
Call to method create_from_id
from undeclared class \Ampache\Repository\Model\Catalog
Open
$catalog = Catalog::create_from_id((int)$catalog_id);
- Exclude checks
Call to method getCatalogId
from undeclared class \Ampache\Repository\Model\Song
Open
$file_target = Catalog::get_cache_path($song->getId(), $song->getCatalogId(), $cache_path, $cache_target);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addDirectory($xml, $sub_id, $dirType): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('id', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('name', (string)$data['f_name']);
- Exclude checks
Reference to instance property mime
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('contentType', (string)$video->mime);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addGenres($xml, $tags): void
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Video
Open
$video->format();
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('owner', (string)$playlist->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('name', (string) self::_checkName($search->get_fullname()));
- Exclude checks
Reference to instance property year
from undeclared class \Ampache\Repository\Model\Video
Open
$xvideo->addAttribute('year', (string)$video->year);
- Exclude checks
Reference to instance property user
from undeclared class \Ampache\Repository\Model\Search
Open
($hide_dupe_searches && $playlist->user == $user_id && in_array($playlist->name, $playlist_names))
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Search
Open
$playlist = new Search((int)str_replace('smart_', '', (string)$plist_id), 'song');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('created', date("c", (int)$playlist->date));
- Exclude checks
Reference to instance property name
from undeclared class \Ampache\Repository\Model\Search
Open
($hide_dupe_searches && $playlist->user == $user_id && in_array($playlist->name, $playlist_names))
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('name', (string)self::_checkName($playlist->get_fullname()));
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->date
Open
$xplaylist->addAttribute('created', date("c", (int)$playlist->date));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('duration', (string)$song->time);
- Exclude checks
Reference to instance property disk
from undeclared class \Ampache\Repository\Model\Song
Open
$disk = $song->disk;
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addVideo($xml, $video, $elementName = 'video'): void
- Exclude checks
Reference to instance property artist
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('artistId', ($song->artist) ? (string)self::_getArtistId($song->artist) : '');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xvideo->addAttribute('title', $video->getFileName());
- Exclude checks
Reference to instance property track
from undeclared class \Ampache\Repository\Model\Song
Open
if ($song->track > 0) {
- Exclude checks
Call to method get_transcode_settings
from undeclared class \Ampache\Repository\Model\Video
Open
$transcode_settings = $video->get_transcode_settings(null, 'api');
- Exclude checks
Call to method get_object_tags
from undeclared class \Ampache\Repository\Model\Tag
Open
$tags = Tag::get_object_tags('song', (int)$song->id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addVideoInfo($xml, $video_id): void
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Song
Open
$tags = Tag::get_object_tags('song', (int)$song->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('songCount', (string)$songcount);
- Exclude checks
Reference to instance property mime
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('contentType', (string)$song->mime);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('duration', (string)$duration);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('path', (string)$song->file);
- Exclude checks
Argument 2 (target)
is null
but \Ampache\Module\Playback\Stream::get_transcode_format()
takes string
defined at /code/src/Module/Playback/Stream.php:104
Open
: Stream::get_transcode_format($song->type, null, 'api');
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Song
Open
if (!empty($transcode_type) && $song->type !== $transcode_type) {
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addDirectory_Catalog($xml, $catalog_id): void
- Exclude checks
Parameter $videos
has undeclared type \Ampache\Repository\Model\Video[]
Open
public static function addVideos($xml, $videos): void
- Exclude checks
Call to method get_object_tags
from undeclared class \Ampache\Repository\Model\Tag
Open
$tags = Tag::get_object_tags('video', (int)$video->id);
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Video
Open
$valid_types = Stream::get_stream_types_for_type($video->type, 'api');
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->name
Open
$playlist_names[] = $playlist->name;
- Exclude checks
Reference to undeclared property \Ampache\Repository\Model\Playlist->username
Open
$xplaylist->addAttribute('owner', (string)$playlist->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsong->addAttribute('transcodedContentType', Song::type_to_mime($transcode_type));
- Exclude checks
Call to method type_to_mime
from undeclared class \Ampache\Repository\Model\Song
Open
$xsong->addAttribute('transcodedContentType', Song::type_to_mime($transcode_type));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('id', (string)$sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xdir->addAttribute('parent', (string)$data['catalog_id']);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Video
Open
$tags = Tag::get_object_tags('video', (int)$video->id);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Video
Open
self::_setIfStarred($xvideo, 'video', $video->id);
- Exclude checks
Checking instanceof against undeclared class \Ampache\Repository\Model\Search
Open
if ($playlist instanceof Search) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('public', ($playlist->type != "private") ? "true" : "false");
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addNowPlaying($xml, $data): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int) $artist_id);
- Exclude checks
Parameter $user
has undeclared type \Ampache\Repository\Model\User
Open
public static function addUser($xml, $user): void
- Exclude checks
Call to deprecated function \Ampache\Module\Authorization\Access::check()
defined at /code/src/Module/Authorization/Access.php:154
Open
$xuser->addAttribute('jukeboxRole', (AmpConfig::get('allow_localplay_playback') && AmpConfig::get('localplay_controller') && Access::check('localplay', 5)) ? 'true' : 'false');
- Exclude checks
Reference to instance property name
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$xradio->addAttribute('name', (string)self::_checkName($radio->name));
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Share
Open
$share = new Share($share_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('username', (string)$user->username);
- Exclude checks
Reference to instance property creation_date
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('created', date("c", (int)$share->creation_date));
- Exclude checks
Reference to instance property lastvisit_date
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('lastVisited', date("c", (int)$share->lastvisit_date));
- Exclude checks
Reference to instance property object_type
from undeclared class \Ampache\Repository\Model\Share
Open
} elseif ($share->object_type == 'album') {
- Exclude checks
Reference to instance property username
from undeclared class \Ampache\Repository\Model\Search
Open
$xplaylist->addAttribute('owner', (string)$search->username);
- Exclude checks
Call to method get_total_duration
from undeclared class \Ampache\Repository\Model\Search
Open
$duration = (count($allitems) > 0) ? Search::get_total_duration($allitems) : 0;
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int) $artist_id);
- Exclude checks
Reference to instance property username
from undeclared class \Ampache\Repository\Model\User
Open
$xuser->addAttribute('username', (string)$user->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('downloadRole', Preference::get_by_user($user->id, 'download') ? 'true' : 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('commentRole', (AmpConfig::get('social')) ? 'true' : 'false');
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('mediumImageUrl', htmlentities($info['mediumphoto']));
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('musicBrainzId', (string)$artist->mbid);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('videoConversionRole', 'false');
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addShare($xml, $share): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('created', date("c", (int)$share->creation_date));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xjbox->addAttribute('gain', (string)$status['volume']);
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('smallImageUrl', htmlentities($info['smallphoto']));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('changed', date("c", time()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('adminRole', $isAdmin ? 'true' : 'false');
- Exclude checks
Call to method isNew
from undeclared class \Ampache\Repository\Model\User
Open
if ($user->isNew() === false) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xradio->addAttribute('id', (string)$radio->id);
- Exclude checks
Reference to instance property url
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$xradio->addAttribute('streamUrl', (string)$radio->url);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('duration', (string)$duration);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('duration', (string)$search->last_duration);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$track->addAttribute('playerId', (string)$row['agent']);
- Exclude checks
Reference to instance property access
from undeclared class \Ampache\Repository\Model\User
Open
$isAdmin = ($user->access === 100);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('jukeboxRole', (AmpConfig::get('allow_localplay_playback') && AmpConfig::get('localplay_controller') && Access::check('localplay', 5)) ? 'true' : 'false');
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addInternetRadioStations($xml, $radios): void
- Exclude checks
Reference to instance property public_url
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('url', (string)$share->public_url);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('description', (string)$share->description);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xjbox->addAttribute('position', '0'); // TODO Not supported
- Exclude checks
Call to method get_lyrics
from undeclared class \Ampache\Repository\Model\Song
Open
$lyrics = $song->get_lyrics();
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('mediumImageUrl', htmlentities($info['mediumphoto']));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('owner', (string)$search->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplayqueue->addAttribute('changedBy', (string)$changedBy);
- Exclude checks
Reference to instance property access
from undeclared class \Ampache\Repository\Model\User
Open
$isManager = ($user->access >= 75);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addUsers($xml, $users): void
- Exclude checks
Reference to instance property max_counter
from undeclared class \Ampache\Repository\Model\Share
Open
if ($share->max_counter === 0 || $share->counter < $share->max_counter) {
- Exclude checks
Reference to instance property user
from undeclared class \Ampache\Repository\Model\Share
Open
$user = new User($share->user);
- Exclude checks
Reference to instance property expire_days
from undeclared class \Ampache\Repository\Model\Share
Open
if ($share->expire_days > 0) {
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('musicBrainzId', $album->mbid);
- Exclude checks
Reference to instance property last_duration
from undeclared class \Ampache\Repository\Model\Search
Open
$xplaylist->addAttribute('duration', (string)$search->last_duration);
- Exclude checks
Call to method get_items
from undeclared class \Ampache\Repository\Model\User_Playlist
Open
$items = $playQueue->get_items();
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('shareRole', Preference::get_by_user($user->id, 'share') ? 'true' : 'false');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$xradio->addAttribute('id', (string)$radio->id);
- Exclude checks
Parameter $share
has undeclared type \Ampache\Repository\Model\Share
Open
private static function addShare($xml, $share): void
- Exclude checks
Reference to instance property username
from undeclared class \Ampache\Repository\Model\User
Open
$xshare->addAttribute('username', (string)$user->username);
- Exclude checks
Reference to instance property lastvisit_date
from undeclared class \Ampache\Repository\Model\Share
Open
if ($share->lastvisit_date > 0) {
- Exclude checks
Reference to instance property mbid
from undeclared class \Ampache\Repository\Model\Artist
Open
$xartist->addChild('musicBrainzId', (string)$artist->mbid);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('public', ($search->type != "private") ? "true" : "false");
- Exclude checks
Reference to instance property date
from undeclared class \Ampache\Repository\Model\Search
Open
$xplaylist->addAttribute('created', date("c", (int)$search->date));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('coverArt', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('scrobblingEnabled', 'true');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\User
Open
$xuser->addAttribute('shareRole', Preference::get_by_user($user->id, 'share') ? 'true' : 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('lastVisited', date("c", (int)$share->lastvisit_date));
- Exclude checks
Reference to instance property creation_date
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('expires', date("c", (int)$share->creation_date + ($share->expire_days * 86400)));
- Exclude checks
Reference to instance property object_id
from undeclared class \Ampache\Repository\Model\Share
Open
$songs = static::getSongRepository()->getByAlbum($share->object_id);
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('largeImageUrl', htmlentities($info['largephoto']));
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('largeImageUrl', htmlentities($info['largephoto']));
- Exclude checks
Call to method get_items
from undeclared class \Ampache\Repository\Model\Search
Open
$allitems = $search->get_items();
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('songCount', (string)$search->last_count);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('id', (string)$share->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('url', (string)$share->public_url);
- Exclude checks
Reference to instance property object_id
from undeclared class \Ampache\Repository\Model\Share
Open
$playlist = new Playlist($share->object_id);
- Exclude checks
Return type of addJukeboxStatus()
is undeclared type \SimpleXMLElement
Open
public static function addJukeboxStatus($xml, LocalPlay $localplay, $elementName = 'jukeboxStatus'): SimpleXMLElement
- Exclude checks
Reference to instance property mbid
from undeclared class \Ampache\Repository\Model\Album
Open
$xartist->addChild('musicBrainzId', $album->mbid);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('created', date("c", (int)$search->date));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addRandomSongs($xml, $songs): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int) $artist_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addStarred($xml, $artists, $albums, $songs): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addStarred2($xml, $artists, $albums, $songs): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('username', (string)$user->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xradio->addAttribute('name', (string)self::_checkName($radio->name));
- Exclude checks
Reference to instance property description
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('description', (string)$share->description);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('expires', date("c", (int)$share->creation_date + ($share->expire_days * 86400)));
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
$song = new Song($song_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addAlbumInfo($xml, $info): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addArtistInfo($xml, $info, $similars, $elementName = 'artistInfo'): void
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('biography', htmlspecialchars($biography));
- Exclude checks
Parameter $playQueue
has undeclared type \Ampache\Repository\Model\User_Playlist
Open
public static function addPlayQueue($xml, $playQueue, $username): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addPlayQueue($xml, $playQueue, $username): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addSearchResult2($xml, $artists, $albums, $songs): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int) $artist_id);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addUser($xml, $user): void
- Exclude checks
Reference to instance property email
from undeclared class \Ampache\Repository\Model\User
Open
$xuser->addAttribute('email', (string)$user->email);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('settingsRole', 'true');
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\User
Open
$xuser->addAttribute('downloadRole', Preference::get_by_user($user->id, 'download') ? 'true' : 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('coverArtRole', $isManager ? 'true' : 'false');
- Exclude checks
Reference to instance property site_url
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$xradio->addAttribute('homepageUrl', (string)$radio->site_url);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('id', (string)$share->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xshare->addAttribute('visitCount', (string)$share->counter);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addLyrics($xml, $artist, $title, $song_id): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xlyrics->addAttribute('title', (string)$title);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addTopSongs($xml, $songs): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addInternetRadioStation($xml, $radio): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\User
Open
$user = new User($share->user);
- Exclude checks
Reference to instance property object_type
from undeclared class \Ampache\Repository\Model\Share
Open
} elseif ($share->object_type == 'playlist') {
- Exclude checks
Call to deprecated function \Ampache\Module\Api\Subsonic_Xml_Data::getSongRepository()
defined at /code/src/Module/Api/Subsonic_Xml_Data.php:1807
Open
$songs = static::getSongRepository()->getByAlbum($share->object_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addJukeboxStatus($xml, LocalPlay $localplay, $elementName = 'jukeboxStatus'): SimpleXMLElement
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album((int) $info['id']);
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('smallImageUrl', htmlentities($info['smallphoto']));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('songCount', (string)count($allitems));
- Exclude checks
Reference to instance property last_count
from undeclared class \Ampache\Repository\Model\Search
Open
$xplaylist->addAttribute('songCount', (string)$search->last_count);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplayqueue->addAttribute('position', (string)($current['current_time'] * 1000));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplayqueue->addAttribute('username', (string)$username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplayqueue->addAttribute('changed', $date->format("c"));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('email', (string)$user->email);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('playlistRole', 'true');
- Exclude checks
Reference to instance property counter
from undeclared class \Ampache\Repository\Model\Share
Open
if ($share->max_counter === 0 || $share->counter < $share->max_counter) {
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Search
Open
$xplaylist->addAttribute('name', (string) self::_checkName($search->get_fullname()));
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Search
Open
$xplaylist->addAttribute('public', ($search->type != "private") ? "true" : "false");
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('podcastRole', (AmpConfig::get('podcast')) ? 'true' : 'false');
- Exclude checks
Parameter $radio
has undeclared type \Ampache\Repository\Model\Live_Stream
Open
private static function addInternetRadioStation($xml, $radio): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xjbox->addAttribute('currentIndex', (string)$index);
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$xartist->addChild('notes', htmlspecialchars(trim((string)$info['summary'])));
- Exclude checks
Call to method get_current_object
from undeclared class \Ampache\Repository\Model\User_Playlist
Open
$current = $playQueue->get_current_object();
- Exclude checks
Call to method get_time
from undeclared class \Ampache\Repository\Model\User_Playlist
Open
$play_time = date("Y-m-d H:i:s", $playQueue->get_time());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplayqueue->addAttribute('current', (string)self::_getSongId($current['object_id']));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xuser->addAttribute('streamRole', 'true');
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Live_Stream
Open
$radio = new Live_Stream((int)$radio_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xradio->addAttribute('streamUrl', (string)$radio->url);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xradio->addAttribute('homepageUrl', (string)$radio->site_url);
- Exclude checks
Parameter $shares
has undeclared type \Ampache\Module\Api\list<int></int>
Open
public static function addShares($xml, $shares): void
- Exclude checks
Reference to instance property expire_days
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('expires', date("c", (int)$share->creation_date + ($share->expire_days * 86400)));
- Exclude checks
Reference to instance property counter
from undeclared class \Ampache\Repository\Model\Share
Open
$xshare->addAttribute('visitCount', (string)$share->counter);
- Exclude checks
Reference to instance property object_type
from undeclared class \Ampache\Repository\Model\Share
Open
if ($share->object_type == 'song') {
- Exclude checks
Reference to instance property object_id
from undeclared class \Ampache\Repository\Model\Share
Open
self::addSong($xshare, $share->object_id, "entry");
- Exclude checks
Call to method fill_ext_info
from undeclared class \Ampache\Repository\Model\Song
Open
$song->fill_ext_info('lyrics');
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Artist
Open
$artist = new Artist((int) $info['id']);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchannel->addAttribute('status', 'completed');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xplaylist->addAttribute('coverArt', $sub_id);
- Exclude checks
Reference to instance property client
from undeclared class \Ampache\Repository\Model\User_Playlist
Open
$changedBy = $playQueue->client ?? '';
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addSongsByGenre($xml, $songs): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$track->addAttribute('username', (string)$row['client']->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$track->addAttribute('minutesAgo', (string)(abs((time() - ($row['expire'] - $row['media']->time)) / 60)));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addSearchResult3($xml, $artists, $albums, $songs): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Album
Open
$album = new Album($album_id);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\User
Open
$user = new User($user_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addShares($xml, $shares): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addJukeboxPlaylist($xml, LocalPlay $localplay): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xjbox->addAttribute('playing', ($status['state'] == 'play') ? 'true' : 'false');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xlyrics->addAttribute('artist', (string)$artist);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addArtistInfo2($xml, $info, $similars): void
- Exclude checks
Parameter $bookmark
has undeclared type \Ampache\Repository\Model\Bookmark
Open
private static function addBookmark($xml, $bookmark): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('parent', $subParent);
- Exclude checks
Reference to instance property mime
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('contentType', (string)$episode->mime);
- Exclude checks
Call to method getSenderUserId
from undeclared class \Ampache\Repository\Model\PrivateMsg
Open
$user = new User($message->getSenderUserId());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$response->addAttribute('serverVersion', Api::$version);
- Exclude checks
Return type of _createFailedResponse()
is undeclared type \SimpleXMLElement
Open
private static function _createFailedResponse($function = ''): SimpleXMLElement
- Exclude checks
Call to method get_flag
from undeclared class \Ampache\Repository\Model\Userflag
Open
$result = $starred->get_flag(null, true);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode = new Podcast_Episode($episode_id);
- Exclude checks
Reference to instance property creation_date
from undeclared class \Ampache\Repository\Model\Bookmark
Open
$xbookmark->addAttribute('created', date("c", (int)$bookmark->creation_date));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('isDir', "false");
- Exclude checks
Parameter $user
has undeclared type \Ampache\Repository\Model\User
Open
public static function addScanStatus($xml, $user): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\User
Open
$user = new User($message->getSenderUserId());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('username', (string)$user->username);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$response->addAttribute('version', (string)$version);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xml->addAttribute('starred', date("Y-m-d\TH:i:s\Z", (int)$result[1]));
- Exclude checks
Return type of addChildToResultXml()
is undeclared type \SimpleXMLElement
Open
private static function addChildToResultXml(SimpleXMLElement $xml, string $qualifiedName, ?string $value = null): SimpleXMLElement
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addSimilarSongs($xml, $similar_songs, $child): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addSimilarSongs2($xml, $similar_songs, $child): void
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Podcast
Open
$podcast->format();
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$sub_id = (string)self::_getPodcastEpisodeId($episode->id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('title', self::_checkName($episode->get_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('username', (string)$user->fullname);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('time', (string)($message->getCreationDate() * 1000));
- Exclude checks
Return type of _getAmpacheObject()
is undeclared type \Ampache\Repository\Model\Podcast_Episode
Open
public static function _getAmpacheObject($object_id)
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Video
Open
return new Video(Subsonic_Xml_Data::_getAmpacheId($object_id));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addPodcasts($xml, $podcasts, $includeEpisodes = true): void
- Exclude checks
Call to method getEpisodeIds
from undeclared class \Ampache\Repository\Model\Podcast
Open
$episodes = $podcast->getEpisodeIds();
- Exclude checks
Reference to instance property object_type
from undeclared class \Ampache\Repository\Model\Bookmark
Open
} elseif ($bookmark->object_type == "video") {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchannel->addAttribute('description', $podcast->get_description());
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Video
Open
self::addVideo($xbookmark, new Video($bookmark->object_id), 'entry');
- Exclude checks
Call to method get_description
from undeclared class \Ampache\Repository\Model\Podcast
Open
$xchannel->addAttribute('description', $podcast->get_description());
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
self::addPodcastEpisode($xbookmark, new Podcast_Episode($bookmark->object_id), 'entry');
- Exclude checks
Reference to instance property update_date
from undeclared class \Ampache\Repository\Model\Bookmark
Open
$xbookmark->addAttribute('changed', date("c", (int)$bookmark->update_date));
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('title', self::_checkName($episode->get_fullname()));
- Exclude checks
Reference to instance property state
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('status', (string)$episode->state);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('coverArt', $subParent);
- Exclude checks
Call to method get_server_counts
from undeclared class \Ampache\Repository\Model\Catalog
Open
$counts = Catalog::get_server_counts($user->id ?? 0);
- Exclude checks
Call to method getMessage
from undeclared class \Ampache\Repository\Model\PrivateMsg
Open
$xbookmark->addAttribute('message', (string)$message->getMessage());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xscan->addAttribute('count', (string)$count);
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, 'API success in function ' . $function . '-' . $version, 5);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addMessage($xml, $message): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$response->addAttribute('status', (string)$status);
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode->format();
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addBookmark($xml, $bookmark): void
- Exclude checks
Parameter $episode
has undeclared type \Ampache\Repository\Model\Podcast_Episode
Open
private static function addPodcastEpisode($xml, $episode, $elementName = 'episode'): void
- Exclude checks
Call to deprecated function \Ampache\Module\Api\Subsonic_Xml_Data::getPodcastRepository()
defined at /code/src/Module/Api/Subsonic_Xml_Data.php:1827
Open
$podcastRepository = self::getPodcastRepository();
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('description', self::_checkName($episode->get_description()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchannel->addAttribute('url', $podcast->getFeedUrl());
- Exclude checks
Call to method addChild
from undeclared class \SimpleXMLElement
Open
$child = $xml->addChild($qualifiedName, $value);
- Exclude checks
Call to method has_art
from undeclared class \Ampache\Repository\Model\Podcast
Open
if ($podcast->has_art()) {
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addBookmarks($xml, $bookmarks): void
- Exclude checks
Reference to instance property object_id
from undeclared class \Ampache\Repository\Model\Bookmark
Open
self::addVideo($xbookmark, new Video($bookmark->object_id), 'entry');
- Exclude checks
Reference to instance property object_type
from undeclared class \Ampache\Repository\Model\Bookmark
Open
} elseif ($bookmark->object_type == "podcast_episode") {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('genre', "Podcast");
- Exclude checks
Reference to instance property file
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
if ($episode->file) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('position', (string)$bookmark->position);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('created', date("c", (int)$bookmark->creation_date));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('channelId', $subParent);
- Exclude checks
Call to method getPubDate
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('publishDate', $episode->getPubDate()->format(DATE_ATOM));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('status', (string)$episode->state);
- Exclude checks
Call to method has_art
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
if ($episode->has_art()) {
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsimilar->addAttribute('name', (string)self::_checkName($similar['name']));
- Exclude checks
Call to method get_fullname
from undeclared class \Ampache\Repository\Model\Podcast
Open
$xchannel->addAttribute('title', self::_checkName($podcast->get_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('comment', (string)$bookmark->comment);
- Exclude checks
Reference to instance property object_id
from undeclared class \Ampache\Repository\Model\Bookmark
Open
self::addSong($xbookmark, $bookmark->object_id, 'entry');
- Exclude checks
Reference to instance property object_id
from undeclared class \Ampache\Repository\Model\Bookmark
Open
self::addPodcastEpisode($xbookmark, new Podcast_Episode($bookmark->object_id), 'entry');
- Exclude checks
Call to method getPodcastName
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('album', $episode->getPodcastName());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('duration', (string)$episode->time);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('contentType', (string)$episode->mime);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addScanStatus($xml, $user): void
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Userflag
Open
$starred = new Userflag($object_id, $objectType);
- Exclude checks
Call to method getFeedUrl
from undeclared class \Ampache\Repository\Model\Podcast
Open
$xchannel->addAttribute('url', $podcast->getFeedUrl());
- Exclude checks
Parameter $bookmarks
has undeclared type \Ampache\Module\Api\list<\Ampache\Repository\Model\Bookmark>
Open
public static function addBookmarks($xml, $bookmarks): void
- Exclude checks
Call to method format
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$episode->format();
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Song
Open
return new Song(Subsonic_Xml_Data::_getAmpacheId($object_id));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addChildToResultXml(SimpleXMLElement $xml, string $qualifiedName, ?string $value = null): SimpleXMLElement
- Exclude checks
Reference to instance property position
from undeclared class \Ampache\Repository\Model\Bookmark
Open
$xbookmark->addAttribute('position', (string)$bookmark->position);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('suffix', (string)$episode->type);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xscan->addAttribute('scanning', "false");
- Exclude checks
Parameter $message
has undeclared type \Ampache\Repository\Model\PrivateMsg
Open
private static function addMessage($xml, $message): void
- Exclude checks
Reference to instance property fullname_public
from undeclared class \Ampache\Repository\Model\User
Open
if ($user->fullname_public) {
- Exclude checks
Return type of _getAmpacheObject()
is undeclared type \Ampache\Repository\Model\Video
Open
public static function _getAmpacheObject($object_id)
- Exclude checks
Call to method getUserName
from undeclared class \Ampache\Repository\Model\Bookmark
Open
$xbookmark->addAttribute('username', $bookmark->getUserName());
- Exclude checks
Reference to instance property comment
from undeclared class \Ampache\Repository\Model\Bookmark
Open
$xbookmark->addAttribute('comment', (string)$bookmark->comment);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('album', $episode->getPodcastName());
- Exclude checks
Reference to instance property size
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('size', (string)$episode->size);
- Exclude checks
Reference to instance property username
from undeclared class \Ampache\Repository\Model\User
Open
$xbookmark->addAttribute('username', (string)$user->username);
- Exclude checks
Return type of _createSuccessResponse()
is undeclared type \SimpleXMLElement
Open
private static function _createSuccessResponse($function = ''): SimpleXMLElement
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xsimilar->addAttribute('id', ($similar['id'] !== null ? (string)self::_getArtistId($similar['id']) : "-1"));
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addNewestPodcasts($xml, $episodes): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('username', $bookmark->getUserName());
- Exclude checks
Call to method get_description
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('description', self::_checkName($episode->get_description()));
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
self::_setIfStarred($xepisode, 'podcast_episode', $episode->id);
- Exclude checks
Reference to instance property file
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$path = basename($episode->file);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\PrivateMsg
Open
$chat = new PrivateMsg($message);
- Exclude checks
Reference to instance property id
from undeclared class \Ampache\Repository\Model\User
Open
$counts = Catalog::get_server_counts($user->id ?? 0);
- Exclude checks
Return type of _createResponse()
is undeclared type \SimpleXMLElement
Open
private static function _createResponse($version, $status = 'ok'): SimpleXMLElement
- Exclude checks
Call to method __construct
from undeclared class \SimpleXMLElement
Open
$response = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><subsonic-response/>');
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$response->addAttribute('xmlns', 'http://subsonic.org/restapi');
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function _setIfStarred($xml, $objectType, $object_id): void
- Exclude checks
Call to method getId
from undeclared class \Ampache\Repository\Model\Podcast
Open
$sub_id = (string)self::_getPodcastId($podcast->getId());
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('publishDate', $episode->getPubDate()->format(DATE_ATOM));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('size', (string)$episode->size);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('path', (string)$path);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('message', (string)$message->getMessage());
- Exclude checks
Call to deprecated function \debug_event()
defined at /code/src/Config/functions.php:651
Open
debug_event(self::class, 'API fail in function ' . $function . '-' . $version, 3);
- Exclude checks
Return type of _getAmpacheObject()
is undeclared type \Ampache\Repository\Model\Song
Open
public static function _getAmpacheObject($object_id)
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchannel->addAttribute('id', $sub_id);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchannel->addAttribute('title', self::_checkName($podcast->get_fullname()));
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xchannel->addAttribute('coverArt', 'pod-' . $sub_id);
- Exclude checks
Parameter $episodes
has undeclared type \Ampache\Repository\Model\Podcast_Episode[]
Open
public static function addNewestPodcasts($xml, $episodes): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xbookmark->addAttribute('changed', date("c", (int)$bookmark->update_date));
- Exclude checks
Reference to instance property object_type
from undeclared class \Ampache\Repository\Model\Bookmark
Open
if ($bookmark->object_type == "song") {
- Exclude checks
Reference to instance property podcast
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$subParent = (string)self::_getPodcastId($episode->podcast);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('id', $sub_id);
- Exclude checks
Reference to instance property time
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('duration', (string)$episode->time);
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$xepisode->addAttribute('streamId', $sub_id);
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
public static function addChatMessages($xml, $messages): void
- Exclude checks
Call to method addAttribute
from undeclared class \SimpleXMLElement
Open
$response->addAttribute('type', 'ampache');
- Exclude checks
Parameter $podcasts
has undeclared type \Ampache\Repository\Model\Podcast[]
Open
public static function addPodcasts($xml, $podcasts, $includeEpisodes = true): void
- Exclude checks
Parameter $xml
has undeclared type \SimpleXMLElement
Open
private static function addPodcastEpisode($xml, $episode, $elementName = 'episode'): void
- Exclude checks
Reference to instance property type
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
$xepisode->addAttribute('suffix', (string)$episode->type);
- Exclude checks
Reference to instance property fullname
from undeclared class \Ampache\Repository\Model\User
Open
$xbookmark->addAttribute('username', (string)$user->fullname);
- Exclude checks
Call to method getCreationDate
from undeclared class \Ampache\Repository\Model\PrivateMsg
Open
$xbookmark->addAttribute('time', (string)($message->getCreationDate() * 1000));
- Exclude checks
Reference to static property version
from undeclared class \Ampache\Module\Api\Api
Open
$response->addAttribute('serverVersion', Api::$version);
- Exclude checks
Call to method __construct
from undeclared class \Ampache\Repository\Model\Podcast_Episode
Open
return new Podcast_Episode(Subsonic_Xml_Data::_getAmpacheId($object_id));
- Exclude checks
Similar blocks of code found in 4 locations. Consider refactoring. Open
public static function addStarred($xml, $artists, $albums, $songs): void
{
$xstarred = self::addChildToResultXml($xml, htmlspecialchars('starred'));
foreach ($artists as $artist_id) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 131.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
public static function addSearchResult2($xml, $artists, $albums, $songs): void
{
$xresult = self::addChildToResultXml($xml, htmlspecialchars('searchResult2'));
foreach ($artists as $artist_id) {
$artist = new Artist((int) $artist_id);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 131.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
public static function addStarred2($xml, $artists, $albums, $songs): void
{
$xstarred = self::addChildToResultXml($xml, htmlspecialchars('starred2'));
foreach ($artists as $artist_id) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 131.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
public static function addSearchResult3($xml, $artists, $albums, $songs): void
{
$xresult = self::addChildToResultXml($xml, htmlspecialchars('searchResult3'));
foreach ($artists as $artist_id) {
$artist = new Artist((int) $artist_id);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 131.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
The parameter $video_id is not named in camelCase. Open
public static function addVideoInfo($xml, $video_id): void
{
$xvideoinfo = self::addChildToResultXml($xml, 'videoinfo');
$xvideoinfo->addAttribute('id', (string)$video_id);
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $user_id is not named in camelCase. Open
public static function addPlaylists($xml, $user_id, $playlists, $smartplaylists = array(), $hide_dupe_searches = false): void
{
$playlist_names = array();
$xplaylists = self::addChildToResultXml($xml, 'playlists');
foreach ($playlists as $plist_id) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $similar_songs is not named in camelCase. Open
public static function addSimilarSongs($xml, $similar_songs, $child): void
{
$xsimilar = self::addChildToResultXml($xml, htmlspecialchars($child));
foreach ($similar_songs as $similar_song) {
if ($similar_song['id'] !== null) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $artist_id is not named in camelCase. Open
private static function _getArtistId($artist_id): int
{
return ((int)$artist_id) + self::AMPACHEID_ARTIST;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $artist_id is not named in camelCase. Open
public static function _isArtist($artist_id): bool
{
$artist_id = self::_cleanId($artist_id);
return ($artist_id >= self::AMPACHEID_ARTIST && $artist_id < self::AMPACHEID_ALBUM);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $plist_id is not named in camelCase. Open
private static function _getSmartPlaylistId($plist_id): int
{
return $plist_id + self::AMPACHEID_SMARTPL;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $video_id is not named in camelCase. Open
public static function _isVideo($video_id): bool
{
$video_id = self::_cleanId($video_id);
return ($video_id >= self::AMPACHEID_VIDEO && $video_id < self::AMPACHEID_PODCAST);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $song_id is not named in camelCase. Open
public static function addSong($xml, $song_id, $elementName = 'song'): SimpleXMLElement
{
$song = new Song($song_id);
if ($song->isNew()) {
return $xml;
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $hide_dupe_searches is not named in camelCase. Open
public static function addPlaylists($xml, $user_id, $playlists, $smartplaylists = array(), $hide_dupe_searches = false): void
{
$playlist_names = array();
$xplaylists = self::addChildToResultXml($xml, 'playlists');
foreach ($playlists as $plist_id) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $similar_songs is not named in camelCase. Open
public static function addSimilarSongs2($xml, $similar_songs, $child): void
{
$xsimilar = self::addChildToResultXml($xml, htmlspecialchars($child));
foreach ($similar_songs as $similar_song) {
if ($similar_song['id'] !== null) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $video_id is not named in camelCase. Open
private static function _getVideoId($video_id): int
{
return $video_id + Subsonic_Xml_Data::AMPACHEID_VIDEO;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $episode_id is not named in camelCase. Open
private static function _getPodcastEpisodeId($episode_id): int
{
return $episode_id + self::AMPACHEID_PODCASTEP;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $object_id is not named in camelCase. Open
public static function _getAmpacheType($object_id): string
{
if (self::_isArtist($object_id)) {
return "artist";
} elseif (self::_isAlbum($object_id)) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The class Subsonic_Xml_Data is not named in CamelCase. Open
class Subsonic_Xml_Data
{
public const API_VERSION = "1.16.1";
public const SSERROR_GENERIC = 0;
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The parameter $sub_id is not named in camelCase. Open
private static function addDirectory_Artist($xml, $sub_id): void
{
$artist_id = self::_getAmpacheId($sub_id);
$data = Artist::get_id_array($artist_id);
$xdir = self::addChildToResultXml($xml, 'directory');
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $catalog_id is not named in camelCase. Open
private static function addDirectory_Catalog($xml, $catalog_id): void
{
$catalog = Catalog::create_from_id((int)$catalog_id);
if ($catalog === null) {
return;
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $sub_id is not named in camelCase. Open
public static function addDirectory($xml, $sub_id, $dirType): void
{
switch ($dirType) {
case 'artist':
self::addDirectory_Artist($xml, $sub_id);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $song_id is not named in camelCase. Open
private static function _getSongId($song_id): int
{
return ((int)$song_id) + self::AMPACHEID_SONG;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $object_id is not named in camelCase. Open
public static function _getAmpacheObject($object_id)
{
if (Subsonic_Xml_Data::_isSong($object_id)) {
return new Song(Subsonic_Xml_Data::_getAmpacheId($object_id));
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $object_id is not named in camelCase. Open
public static function _getAmpacheId($object_id): int
{
return (self::_cleanId($object_id) % self::AMPACHEID_ARTIST);
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $episode_id is not named in camelCase. Open
public static function _isPodcastEpisode($episode_id): bool
{
$episode_id = self::_cleanId($episode_id);
return ($episode_id >= self::AMPACHEID_PODCASTEP && $episode_id < self::AMPACHEID_PLAYLIST);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $podcast_id is not named in camelCase. Open
public static function _isPodcast($podcast_id): bool
{
$podcast_id = self::_cleanId($podcast_id);
return ($podcast_id >= self::AMPACHEID_PODCAST && $podcast_id < self::AMPACHEID_PODCASTEP);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $plist_id is not named in camelCase. Open
public static function _isSmartPlaylist($plist_id): bool
{
$plist_id = self::_cleanId($plist_id);
return ($plist_id >= self::AMPACHEID_SMARTPL && $plist_id < self::AMPACHEID_VIDEO);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $plist_id is not named in camelCase. Open
public static function _isPlaylist($plist_id): bool
{
$plist_id = self::_cleanId($plist_id);
return ($plist_id >= self::AMPACHEID_PLAYLIST);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $object_id is not named in camelCase. Open
private static function _setIfStarred($xml, $objectType, $object_id): void
{
if (InterfaceImplementationChecker::is_library_item($objectType)) {
if (AmpConfig::get('ratings')) {
$starred = new Userflag($object_id, $objectType);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $album_id is not named in camelCase. Open
public static function _isAlbum($album_id): bool
{
$album_id = self::_cleanId($album_id);
return ($album_id >= self::AMPACHEID_ALBUM && $album_id < self::AMPACHEID_SONG);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $album_id is not named in camelCase. Open
private static function addDirectory_Album($xml, $album_id): void
{
$album = new Album(self::_getAmpacheId($album_id));
$album->format();
/** @var SimpleXMLElement $xdir */
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $song_id is not named in camelCase. Open
public static function addLyrics($xml, $artist, $title, $song_id): void
{
$song = new Song($song_id);
$song->fill_ext_info('lyrics');
$lyrics = $song->get_lyrics();
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $plist_id is not named in camelCase. Open
private static function _getPlaylistId($plist_id): int
{
return $plist_id + self::AMPACHEID_PLAYLIST;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $object_id is not named in camelCase. Open
private static function _cleanId($object_id): int
{
// Remove all al-, ar-, ... prefixes
$tpos = strpos((string)$object_id, "-");
if ($tpos !== false) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $object_ids is not named in camelCase. Open
public static function _getAmpacheIdArrays($object_ids): array
{
$ampidarrays = array();
$track = 1;
foreach ($object_ids as $object_id) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $album_id is not named in camelCase. Open
private static function _getAlbumId($album_id): int
{
return ((int)$album_id) + self::AMPACHEID_ALBUM;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $podcast_id is not named in camelCase. Open
private static function _getPodcastId($podcast_id): int
{
return $podcast_id + self::AMPACHEID_PODCAST;
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $song_id is not named in camelCase. Open
public static function _isSong($song_id): bool
{
$song_id = self::_cleanId($song_id);
return ($song_id >= self::AMPACHEID_SONG && $song_id < self::AMPACHEID_SMARTPL);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Method name "_isVideo" should not be prefixed with an underscore to indicate visibility Open
public static function _isVideo($video_id): bool
- Exclude checks
Method name "_getArtistId" should not be prefixed with an underscore to indicate visibility Open
private static function _getArtistId($artist_id): int
- Exclude checks
Method name "_isSong" should not be prefixed with an underscore to indicate visibility Open
public static function _isSong($song_id): bool
- Exclude checks
Method name "_getAlbumId" should not be prefixed with an underscore to indicate visibility Open
private static function _getAlbumId($album_id): int
- Exclude checks
Method name "_getVideoId" should not be prefixed with an underscore to indicate visibility Open
private static function _getVideoId($video_id): int
- Exclude checks
Method name "_createFailedResponse" should not be prefixed with an underscore to indicate visibility Open
private static function _createFailedResponse($function = ''): SimpleXMLElement
- Exclude checks
Method name "_isPodcast" should not be prefixed with an underscore to indicate visibility Open
public static function _isPodcast($podcast_id): bool
- Exclude checks
Method name "_checkName" should not be prefixed with an underscore to indicate visibility Open
private static function _checkName($name): string
- Exclude checks
Method name "_getAmpacheObject" should not be prefixed with an underscore to indicate visibility Open
public static function _getAmpacheObject($object_id)
- Exclude checks
Method name "_isPlaylist" should not be prefixed with an underscore to indicate visibility Open
public static function _isPlaylist($plist_id): bool
- Exclude checks
Method name "_getSmartPlaylistId" should not be prefixed with an underscore to indicate visibility Open
private static function _getSmartPlaylistId($plist_id): int
- Exclude checks
Method name "_createSuccessResponse" should not be prefixed with an underscore to indicate visibility Open
private static function _createSuccessResponse($function = ''): SimpleXMLElement
- Exclude checks
Method name "_getPodcastEpisodeId" should not be prefixed with an underscore to indicate visibility Open
private static function _getPodcastEpisodeId($episode_id): int
- Exclude checks
Method name "_cleanId" should not be prefixed with an underscore to indicate visibility Open
private static function _cleanId($object_id): int
- Exclude checks
Method name "_createResponse" should not be prefixed with an underscore to indicate visibility Open
private static function _createResponse($version, $status = 'ok'): SimpleXMLElement
- Exclude checks
Method name "_getPodcastId" should not be prefixed with an underscore to indicate visibility Open
private static function _getPodcastId($podcast_id): int
- Exclude checks
Method name "_getAmpacheType" should not be prefixed with an underscore to indicate visibility Open
public static function _getAmpacheType($object_id): string
- Exclude checks
Method name "_isPodcastEpisode" should not be prefixed with an underscore to indicate visibility Open
public static function _isPodcastEpisode($episode_id): bool
- Exclude checks
Method name "_setIfStarred" should not be prefixed with an underscore to indicate visibility Open
private static function _setIfStarred($xml, $objectType, $object_id): void
- Exclude checks
Method name "_isAlbum" should not be prefixed with an underscore to indicate visibility Open
public static function _isAlbum($album_id): bool
- Exclude checks
Method name "_getSongId" should not be prefixed with an underscore to indicate visibility Open
private static function _getSongId($song_id): int
- Exclude checks
Method name "_getPlaylistId" should not be prefixed with an underscore to indicate visibility Open
private static function _getPlaylistId($plist_id): int
- Exclude checks
Method name "_getAmpacheId" should not be prefixed with an underscore to indicate visibility Open
public static function _getAmpacheId($object_id): int
- Exclude checks
Method name "_isSmartPlaylist" should not be prefixed with an underscore to indicate visibility Open
public static function _isSmartPlaylist($plist_id): bool
- Exclude checks
Method name "_getAmpacheIdArrays" should not be prefixed with an underscore to indicate visibility Open
public static function _getAmpacheIdArrays($object_ids): array
- Exclude checks
Method name "_isArtist" should not be prefixed with an underscore to indicate visibility Open
public static function _isArtist($artist_id): bool
- Exclude checks
Class name "Subsonic_Xml_Data" is not in camel caps format Open
class Subsonic_Xml_Data
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks