Skip to content

Commit

Permalink
hasTax() for price (#126)
Browse files Browse the repository at this point in the history
* Update Price.php

* Update ProductPriceTest.php

* Update Price.php

* Update Price.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
Larsklopstra and taylorotwell authored Jun 13, 2021
1 parent 4e6020e commit 108ce67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public function tax()
return $this->formatAmount((int) ($this->rawTax() * 100));
}

/**
* Determine if the price has tax.
*
* @return boolean
*/
public function hasTax()
{
return $this->rawTax() > 0;
}

/**
* Get the raw tax amount.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/ProductPriceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ public function test_it_implements_arrayable_and_jsonable()
$this->assertSame($data, $product->jsonSerialize());
$this->assertSame(json_encode($data), $product->toJson());
}

public function test_it_can_check_if_has_tax()
{
$product = $this->product();

$this->assertTrue($product->price()->hasTax());
}

/**
* Get a test product price object.
Expand Down

0 comments on commit 108ce67

Please sign in to comment.