ampache/ampache

View on GitHub
src/Repository/Model/ModelFactory.php

Summary

Maintainability
A
2 hrs
Test Coverage

The class ModelFactory has 21 public methods. Consider refactoring ModelFactory to keep number of public methods under 10.
Open

final class ModelFactory implements ModelFactoryInterface
{
    public function createPlaylist(
        int $id
    ): Playlist {
Severity: Minor
Found in src/Repository/Model/ModelFactory.php by phpmd

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

ModelFactory has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

final class ModelFactory implements ModelFactoryInterface
{
    public function createPlaylist(
        int $id
    ): Playlist {
Severity: Minor
Found in src/Repository/Model/ModelFactory.php - About 2 hrs to fix

    Class "ModelFactory" has 21 methods, which is greater than 20 authorized. Split it into smaller classes.
    Open

    final class ModelFactory implements ModelFactoryInterface

    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.

    The class ModelFactory has a coupling between objects value of 22. Consider to reduce the number of dependencies under 13.
    Open

    final class ModelFactory implements ModelFactoryInterface
    {
        public function createPlaylist(
            int $id
        ): Playlist {
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phpmd

    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

    Return type of createAlbumDisk() is undeclared type \Ampache\Repository\Model\AlbumDisk
    Open

        public function createAlbumDisk(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Song
    Open

            return new Song(
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createTvShow() is undeclared type \Ampache\Repository\Model\TvShow
    Open

        public function createTvShow(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createTmpPlaylist() is undeclared type \Ampache\Repository\Model\Tmp_Playlist
    Open

        public function createTmpPlaylist(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createRating() is undeclared type \Ampache\Repository\Model\Rating
    Open

        public function createRating(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Democratic
    Open

            return new Democratic($democraticId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createUser() is undeclared type \Ampache\Repository\Model\User
    Open

        public function createUser(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Wanted
    Open

            return new Wanted((int) $wantedId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Broadcast
    Open

            return new Broadcast($broadcastId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Album
    Open

            return new Album((int) $albumId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createPodcast() is undeclared type \Ampache\Repository\Model\Podcast
    Open

        public function createPodcast(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\PrivateMsg
    Open

            return new PrivateMsg($privateMessageId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\AlbumDisk
    Open

            return new AlbumDisk((int) $albumDiskId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createArtist() is undeclared type \Ampache\Repository\Model\Artist
    Open

        public function createArtist(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Video
    Open

            return new Video($videoId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createBroadcast() is undeclared type \Ampache\Repository\Model\Broadcast
    Open

        public function createBroadcast(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\User
    Open

            return new User((int) $userId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createSearch() is undeclared type \Ampache\Repository\Model\Search
    Open

        public function createSearch(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createSong() is undeclared type \Ampache\Repository\Model\Song
    Open

        public function createSong(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Returning type \Ampache\Repository\Model\PrivateMsg but createPrivateMsg() is declared to return \Ampache\Repository\Model\PrivateMessageInterface
    Open

            return new PrivateMsg($privateMessageId);
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Parameter $user has undeclared type ?\Ampache\Repository\Model\User
    Open

        public function createSearch(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createWanted() is undeclared type \Ampache\Repository\Model\Wanted
    Open

        public function createWanted(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createLiveStream() is undeclared type \Ampache\Repository\Model\Live_Stream
    Open

        public function createLiveStream(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Live_Stream
    Open

            return new Live_Stream($liveStreamId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createPodcastEpisode() is undeclared type \Ampache\Repository\Model\Podcast_Episode
    Open

        public function createPodcastEpisode(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Tmp_Playlist
    Open

            return new Tmp_Playlist($tmpPlaylistId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Search
    Open

            return new Search((int) $searchId, $searchType, $user);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Rating
    Open

            return new Rating(
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createAlbum() is undeclared type \Ampache\Repository\Model\Album
    Open

        public function createAlbum(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createDemocratic() is undeclared type \Ampache\Repository\Model\Democratic
    Open

        public function createDemocratic(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\TvShow
    Open

            return new TvShow($tvShowId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Return type of createVideo() is undeclared type \Ampache\Repository\Model\Video
    Open

        public function createVideo(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Artist
    Open

            return new Artist((int) $artistId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Podcast
    Open

            return new Podcast($podcastId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Call to method __construct from undeclared class \Ampache\Repository\Model\Podcast_Episode
    Open

            return new Podcast_Episode($podcastEpisodeId);
    Severity: Critical
    Found in src/Repository/Model/ModelFactory.php by phan

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

            int $id
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    The parameter $browse_id is not named in camelCase.
    Open

        public function createBrowse(
            ?int $browse_id = null,
            bool $cached = true
        ): Browse {
            return new Browse(
    Severity: Minor
    Found in src/Repository/Model/ModelFactory.php by phpmd

    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

    There are no issues that match your filters.

    Category
    Status