11<?php
22
3+ declare (strict_types=1 );
4+
35namespace Coduo \PHPHumanizer \Collection ;
46
57use Symfony \Component \Translation \TranslatorInterface ;
@@ -27,7 +29,7 @@ public function __construct(TranslatorInterface $translator, $catalogue = 'oxfor
2729
2830 public function format ($ collection , $ limit = null )
2931 {
30- $ count = count ($ collection );
32+ $ count = \ count ($ collection );
3133
3234 if (0 === $ count ) {
3335 return '' ;
@@ -57,16 +59,16 @@ public function format($collection, $limit = null)
5759 */
5860 private function formatCommaSeparatedWithLimit ($ collection , $ limit , $ count )
5961 {
60- $ display = array_map (function ($ element ) {
62+ $ display = \ array_map (function ($ element ) {
6163 return (string ) $ element ;
62- }, array_slice ($ collection , 0 , $ limit ));
64+ }, \ array_slice ($ collection , 0 , $ limit ));
6365
64- $ moreCount = $ count - count ($ display );
66+ $ moreCount = $ count - \ count ($ display );
6567
66- return $ this ->translator ->transChoice ('comma_separated_with_limit ' , $ moreCount , array (
67- '%list% ' => implode (', ' , $ display ),
68+ return $ this ->translator ->transChoice ('comma_separated_with_limit ' , $ moreCount , [
69+ '%list% ' => \ implode (', ' , $ display ),
6870 '%count% ' => $ moreCount ,
69- ) , $ this ->catalogue );
71+ ] , $ this ->catalogue );
7072 }
7173
7274 /**
@@ -77,14 +79,14 @@ private function formatCommaSeparatedWithLimit($collection, $limit, $count)
7779 */
7880 private function formatCommaSeparated ($ collection , $ count )
7981 {
80- $ display = array_map (function ($ element ) {
82+ $ display = \ array_map (function ($ element ) {
8183 return (string ) $ element ;
82- }, array_slice ($ collection , 0 , $ count - 1 ));
84+ }, \ array_slice ($ collection , 0 , $ count - 1 ));
8385
84- return $ this ->translator ->trans ('comma_separated ' , array (
85- '%list% ' => implode (', ' , $ display ),
86- '%last% ' => (string ) end ($ collection ),
87- ) , $ this ->catalogue );
86+ return $ this ->translator ->trans ('comma_separated ' , [
87+ '%list% ' => \ implode (', ' , $ display ),
88+ '%last% ' => (string ) \ end ($ collection ),
89+ ] , $ this ->catalogue );
8890 }
8991
9092 /**
@@ -94,9 +96,9 @@ private function formatCommaSeparated($collection, $count)
9496 */
9597 private function formatOnlyTwo ($ collection )
9698 {
97- return $ this ->translator ->trans ('only_two ' , array (
99+ return $ this ->translator ->trans ('only_two ' , [
98100 '%first% ' => (string ) $ collection [0 ],
99101 '%second% ' => (string ) $ collection [1 ],
100- ) , $ this ->catalogue );
102+ ] , $ this ->catalogue );
101103 }
102104}
0 commit comments