| Conditions | 19 | 
| Paths | 17 | 
| Total Lines | 94 | 
| Code Lines | 59 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 38 | public static function createHandler($connection): DoctrineCache\Cache  | 
            ||
| 39 |     { | 
            ||
| 40 |         if (!(\is_string($connection) || \is_object($connection))) { | 
            ||
| 41 | throw new TypeError(  | 
            ||
| 42 | \sprintf(  | 
            ||
| 43 | 'Argument 1 passed to %s() must be a string or a connection object, %s given.',  | 
            ||
| 44 | __METHOD__,  | 
            ||
| 45 | \gettype($connection)  | 
            ||
| 46 | )  | 
            ||
| 47 | );  | 
            ||
| 48 | }  | 
            ||
| 49 | |||
| 50 |         switch (true) { | 
            ||
| 51 | case $connection instanceof DoctrineCache\Cache:  | 
            ||
| 52 | return $connection;  | 
            ||
| 53 | |||
| 54 | case $connection instanceof Redis:  | 
            ||
| 55 | $adapter = new DoctrineCache\RedisCache();  | 
            ||
| 56 | |||
| 57 |                 if (!$connection->isConnected()) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 58 |                     throw new InvalidArgumentException('Did you forget to call the \'connect\' method'); | 
            ||
| 59 | }  | 
            ||
| 60 | $adapter->setRedis($connection);  | 
            ||
| 61 | |||
| 62 | return $adapter;  | 
            ||
| 63 | |||
| 64 | case $connection instanceof Memcache:  | 
            ||
| 65 | $adapter = new DoctrineCache\MemcacheCache();  | 
            ||
| 66 | $adapter->setMemcache($connection);  | 
            ||
| 67 | |||
| 68 | return $adapter;  | 
            ||
| 69 | |||
| 70 | case $connection instanceof Memcached:  | 
            ||
| 71 | $adapter = new DoctrineCache\MemcachedCache();  | 
            ||
| 72 | $adapter->setMemcached($connection);  | 
            ||
| 73 | |||
| 74 | return $adapter;  | 
            ||
| 75 | |||
| 76 | case self::isPrefixedAdapter($connection, 'array'):  | 
            ||
| 77 | return new DoctrineCache\ArrayCache();  | 
            ||
| 78 | |||
| 79 | case self::isPrefixedAdapter($connection, 'apcu'):  | 
            ||
| 80 | return new DoctrineCache\ApcuCache();  | 
            ||
| 81 | |||
| 82 | case self::isPrefixedAdapter($connection, 'wincache'):  | 
            ||
| 83 | return new DoctrineCache\WinCacheCache();  | 
            ||
| 84 | |||
| 85 | case self::isPrefixedAdapter($connection, 'zenddata'):  | 
            ||
| 86 | return new DoctrineCache\ZendDataCache();  | 
            ||
| 87 | |||
| 88 | case self::isPrefixedAdapter($connection, 'redis://'):  | 
            ||
| 89 | $adapter = new DoctrineCache\RedisCache();  | 
            ||
| 90 | |||
| 91 | [$host, $port] = self::getPrefixedAdapter($connection, 8);  | 
            ||
| 92 | ($redis = new Redis())->connect($host, (int) $port);  | 
            ||
| 93 | $adapter->setRedis($redis);  | 
            ||
| 94 | |||
| 95 | return $adapter;  | 
            ||
| 96 | |||
| 97 | case self::isPrefixedAdapter($connection, 'memcache://'):  | 
            ||
| 98 | $adapter = new DoctrineCache\MemcacheCache();  | 
            ||
| 99 | |||
| 100 | [$host, $port] = self::getPrefixedAdapter($connection, 11);  | 
            ||
| 101 | ($memcache = new Memcache())->addServer($host, (int) $port);  | 
            ||
| 102 | $adapter->setMemcache($memcache);  | 
            ||
| 103 | |||
| 104 | return $adapter;  | 
            ||
| 105 | |||
| 106 | case self::isPrefixedAdapter($connection, 'memcached://'):  | 
            ||
| 107 | $adapter = new DoctrineCache\MemcachedCache();  | 
            ||
| 108 | |||
| 109 | [$host, $port] = self::getPrefixedAdapter($connection, 12);  | 
            ||
| 110 | ($memcached = new Memcached())->addServer($host, (int) $port);  | 
            ||
| 111 | $adapter->setMemcached($memcached);  | 
            ||
| 112 | |||
| 113 | return $adapter;  | 
            ||
| 114 | |||
| 115 | case self::isPrefixedAdapter($connection, 'file://'):  | 
            ||
| 116 | [$tempDir, $extension] = self::getPrefixedAdapter($connection, 7, false);  | 
            ||
| 117 | |||
| 118 | return new DoctrineCache\FilesystemCache($tempDir, $extension . 'data');  | 
            ||
| 119 | |||
| 120 | case self::isPrefixedAdapter($connection, 'memory://'):  | 
            ||
| 121 | [$tempDir, $extension] = self::getPrefixedAdapter($connection, 9, false);  | 
            ||
| 122 | |||
| 123 | return new DoctrineCache\PhpFileCache($tempDir, $extension . 'php');  | 
            ||
| 124 | |||
| 125 | case self::isPrefixedAdapter($connection, 'sqlite://'):  | 
            ||
| 126 | [$table, $filename] = self::getPrefixedAdapter($connection, 9);  | 
            ||
| 127 | |||
| 128 | return new DoctrineCache\SQLite3Cache(new SQLite3($filename), $table);  | 
            ||
| 129 | }  | 
            ||
| 130 | |||
| 131 | throw new InvalidArgumentException(  | 
            ||
| 132 |             \sprintf('Unsupported Cache Adapter: %s.', \is_object($connection) ? \get_class($connection) : $connection) | 
            ||
| 167 | 
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.