Conditions | 10 |
Paths | 192 |
Total Lines | 39 |
Code Lines | 27 |
Lines | 0 |
Ratio | 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 |
||
30 | public function setUp() |
||
31 | { |
||
32 | if (!getenv('TESTS_ZEND_CACHE_COUCHBASE_ENABLED')) { |
||
33 | $this->markTestSkipped('Enable TESTS_ZEND_CACHE_COUCHBASE_ENABLED to run this test'); |
||
34 | } |
||
35 | if (version_compare('2.0.0', phpversion('couchbase')) > 0) { |
||
36 | try { |
||
37 | new Couchbase(); |
||
38 | $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException"); |
||
39 | } catch (ExtensionNotLoadedException $e) { |
||
40 | $this->markTestSkipped("Missing ext/couchbase version >= 2.0.0"); |
||
41 | } |
||
42 | } |
||
43 | $this->_options = new CouchbaseOptions([ |
||
44 | 'resource_id' => __CLASS__ |
||
45 | ]); |
||
46 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST') && getenv('TESTS_ZEND_CACHE_COUCHBASE_PORT')) { |
||
47 | $this->_options->getResourceManager()->setServer(__CLASS__, [ |
||
|
|||
48 | [getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST'), getenv('TESTS_ZEND_CACHE_COUCHBASE_PORT')] |
||
49 | ]); |
||
50 | } elseif (getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST')) { |
||
51 | $this->_options->getResourceManager()->setServer(__CLASS__, [ |
||
52 | [getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST')] |
||
53 | ]); |
||
54 | } |
||
55 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_USERNAME')) { |
||
56 | $this->_options->getResourceManager()->setUsername(__CLASS__, getenv('TESTS_ZEND_CACHE_COUCHBASE_USERNAME')); |
||
57 | } |
||
58 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_PASSWORD')) { |
||
59 | $this->_options->getResourceManager()->setPassword(__CLASS__, getenv('TESTS_ZEND_CACHE_COUCHBASE_PASSWORD')); |
||
60 | } |
||
61 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_BUCKET')) { |
||
62 | $this->_options->getResourceManager()->setBucket(__CLASS__, getenv('TESTS_ZEND_CACHE_COUCHBASE_BUCKET')); |
||
63 | } |
||
64 | $this->_storage = new Couchbase(); |
||
65 | $this->_storage->setOptions($this->_options); |
||
66 | $this->_storage->flush(); |
||
67 | parent::setUp(); |
||
68 | } |
||
69 | |||
94 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: