Skip to content

Commit

Permalink
Added remove binding from item code method
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberinferno committed Feb 25, 2020
1 parent 426cec5 commit d9de1fb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ItemCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,14 @@ public static function extract($generatedItemCode)
'grade' => $grade
];
}

public static function removeBinding($itemCode)
{
// Extract item code
$extractedItemCode = self::extract($itemCode);
// Regenerate item code without binding and return
$generator = new self($extractedItemCode['itemCode']);
$generator->setGrade($extractedItemCode['grade']);
return $generator->generate();
}
}
21 changes: 21 additions & 0 deletions tests/ItemCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,25 @@ public function testExtract()
$this->assertTrue(array_key_exists('grade', $result));
$this->assertEquals(0, $result['grade']);
}

public function testRemoveBinding()
{
$result = ItemCode::extract(ItemCode::removeBinding(
(new ItemCode(2897))
->setGrade(15)
->setCharacterBindingOnUsage()
->generate()
));
$this->assertEquals(2897, $result['itemCode']);
$this->assertEquals(0, $result['binding']);
$this->assertEquals(15, $result['grade']);
$result = ItemCode::extract(ItemCode::removeBinding(
(new ItemCode(4095))
->setAccountBinding()
->generate()
));
$this->assertEquals(4095, $result['itemCode']);
$this->assertEquals(0, $result['binding']);
$this->assertEquals(0, $result['grade']);
}
}

0 comments on commit d9de1fb

Please sign in to comment.