Completed
Push — master ( 875476...1855ce )
by Dan
02:56
created

FontMetrics::calculateSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 4
crap 1
1
<?php
2
3
namespace SixtyNine\Cloud;
4
5
use SixtyNine\Cloud\Factory\FontsFactory;
6
use SixtyNine\Cloud\Model\Box;
7
8
class FontMetrics
9
{
10
    /** @var \SixtyNine\Cloud\Factory\FontsFactory  */
11
    protected $fontsFactory;
12
13
    /**
14
     * @param FontsFactory $fontsFactory
15
     */
16 6
    public function __construct(FontsFactory $fontsFactory)
17
    {
18 6
        $this->fontsFactory = $fontsFactory;
19 6
    }
20
21
    /**
22
     * @param string $text
23
     * @param string $font
24
     * @param int $fontSize
25
     * @param int $angle
26
     * @return Box
27
     */
28 6
    public function calculateSize($text, $font, $fontSize, $angle = 0)
29
    {
30 6
        $imagineFont = $this->fontsFactory->getImagineFont($font, $fontSize);
31 6
        $imagineBox = $imagineFont->box($text, $angle);
32 6
        return new Box(0, 0, $imagineBox->getWidth(), $imagineBox->getHeight());
33
    }
34
}
35