| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public function withPalette(PaletteInterface $palette) |
||
| 49 | { |
||
| 50 | $image = clone $this; |
||
| 51 | |||
| 52 | if ($image->getColorSpace() === $palette->getColorSpace()) { |
||
| 53 | return $image; |
||
| 54 | } |
||
| 55 | |||
| 56 | if (null === $image->getColorProfile()) { |
||
| 57 | $image = $image->withColorProfile($image->getPalette()->getColorProfile()); |
||
|
|
|||
| 58 | } |
||
| 59 | |||
| 60 | $image = $image |
||
| 61 | ->withColorProfile($palette->getColorProfile()) |
||
| 62 | ->withColorSpace($palette->getColorSpace()); |
||
| 63 | |||
| 64 | return $image; |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: