Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit b35abff

Browse files
author
Jens Schulze
committed
feat(Context): add interface for CurrencyFormatter
1 parent adbb71f commit b35abff

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/Core/Helper/CurrencyFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* $str = $this->format($centAmount, $currency); // '1.234,56 €'
2424
* @package Commercetools\Core\Helper
2525
*/
26-
class CurrencyFormatter
26+
class CurrencyFormatter implements CurrencyFormatterInterface
2727
{
2828
protected $context;
2929

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* @author @jenschude <jens.schulze@commercetools.de>
4+
*/
5+
6+
namespace Commercetools\Core\Helper;
7+
8+
interface CurrencyFormatterInterface
9+
{
10+
/**
11+
* @param $centAmount
12+
* @param $currency
13+
* @return string
14+
*/
15+
public function format($centAmount, $currency);
16+
}

src/Core/Model/Common/Context.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Commercetools\Core\Model\Common;
77

8+
use Commercetools\Core\Helper\CurrencyFormatterInterface;
89
use Pimple\Container;
910
use Psr\Log\LoggerInterface;
1011
use Commercetools\Core\Helper\CurrencyFormatter;
@@ -72,7 +73,7 @@ class Context implements \ArrayAccess
7273
private $languages = [];
7374

7475
/**
75-
* @var CurrencyFormatter
76+
* @var CurrencyFormatterInterface
7677
*/
7778
private $currencyFormatter;
7879

@@ -141,15 +142,15 @@ public function setLanguages(array $languages)
141142
}
142143

143144
/**
144-
* @return CurrencyFormatter
145+
* @return CurrencyFormatterInterface
145146
*/
146147
public function getCurrencyFormatter()
147148
{
148149
return $this->currencyFormatter;
149150
}
150151

151152
/**
152-
* @param CurrencyFormatter $currencyFormatter
153+
* @param CurrencyFormatterInterface $currencyFormatter
153154
* @return Context
154155
*/
155156
public function setCurrencyFormatter($currencyFormatter)

0 commit comments

Comments
 (0)