Completed
Push — GildedRose/AlbertAndMarcos ( c4eed1 )
by Albert
02:33
created

ItemFactory::fromItem()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 20
ccs 11
cts 11
cp 1
rs 8.8571
cc 5
eloc 16
nc 5
nop 1
crap 5
1
<?php
2
3
namespace Kata\GildedRoseKata;
4
5
final class ItemFactory
6
{
7 15
    public static function fromItem(Item $item)
8
    {
9 15
        switch($item->name)
10
        {
11 15
            case AgedBrieItem::ITEM_NAME:
12 1
                return new AgedBrieItem($item);
13
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
14 14
            case SulfurasItem::ITEM_NAME:
15 2
                return new SulfurasItem($item);
16
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
17 12
            case BackstagePassItem::ITEM_NAME:
18 5
                return new BackstagePassItem($item);
19
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
20 7
            case ConjuredItem::ITEM_NAME:
21 4
                return new ConjuredItem($item);
22
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
23
            default:
24 3
                return new BaseItem($item);
25
        }
26
    }
27
}
28