| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 46 | public function testSetters() :void |
||
| 47 | { |
||
| 48 | $client = new Client(); |
||
| 49 | self::assertInstanceOf(ClientInterface::class, $client); |
||
| 50 | |||
| 51 | $client->setCustomValue1('test1'); |
||
| 52 | $client->setCustomValue2('test2'); |
||
| 53 | $client->setBalance(123.45); |
||
| 54 | $client->setCountryId(9); |
||
| 55 | $client->setIndustryId(8); |
||
| 56 | $client->setLanguageId(7); |
||
| 57 | $client->setPaymentTerms(6); |
||
| 58 | $client->setUserId(5); |
||
| 59 | $client->setSizeId(4); |
||
| 60 | $client->setCurrencyId(3); |
||
| 61 | $client->setPaidToDate(123.45); |
||
| 62 | $client->setAddress1('ad1'); |
||
| 63 | $client->setAddress2('ad2'); |
||
| 64 | $client->setCity('city'); |
||
| 65 | $client->setState('state'); |
||
| 66 | $client->setPostalCode('postcode'); |
||
| 67 | $client->setWorkPhone('12345'); |
||
| 68 | $client->setPrivateNotes('note'); |
||
| 69 | $client->setWebsite('wwww'); |
||
| 70 | $client->setVatNumber('1234e'); |
||
| 71 | $client->setIdNumber('1234ee'); |
||
| 72 | $client->setName('name'); |
||
| 73 | $client->setContacts([1,2,3]); |
||
|
|
|||
| 74 | |||
| 75 | self::assertSame('test1', $client->getCustomValue1()); |
||
| 76 | self::assertSame('test2', $client->getCustomValue2()); |
||
| 77 | self::assertNull($client->getLastLogin()); |
||
| 78 | |||
| 79 | self::assertEquals(123.45, $client->getBalance()); |
||
| 80 | self::assertEquals(9, $client->getCountryId()); |
||
| 81 | self::assertEquals(8, $client->getIndustryId()); |
||
| 82 | self::assertEquals(7, $client->getLanguageId()); |
||
| 83 | self::assertEquals(6, $client->getPaymentTerms()); |
||
| 84 | self::assertEquals(5, $client->getUserId()); |
||
| 85 | self::assertEquals(4, $client->getSizeId()); |
||
| 86 | self::assertEquals(3, $client->getCurrencyId()); |
||
| 87 | self::assertEquals(123.45, $client->getPaidToDate()); |
||
| 88 | |||
| 89 | self::assertSame('ad1', $client->getAddress1()); |
||
| 90 | self::assertSame('ad2', $client->getAddress2()); |
||
| 91 | self::assertSame('city', $client->getCity()); |
||
| 92 | self::assertSame('state', $client->getState()); |
||
| 93 | self::assertSame('postcode', $client->getPostalCode()); |
||
| 94 | self::assertSame('12345', $client->getWorkPhone()); |
||
| 95 | self::assertSame('note', $client->getPrivateNotes()); |
||
| 96 | self::assertSame('wwww', $client->getWebsite()); |
||
| 97 | self::assertSame('1234e', $client->getVatNumber()); |
||
| 98 | self::assertSame('1234ee', $client->getIdNumber()); |
||
| 99 | self::assertSame('name', $client->getName()); |
||
| 100 | self::assertNotEmpty($client->getContacts()); |
||
| 101 | |||
| 102 | |||
| 103 | } |
||
| 104 | } |
||
| 105 |
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: