Completed
Push — master ( 6aec97...01562b )
by Derek Stephen
01:48
created

Flag::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 30/10/15
5
 * Time: 17:32
6
 */
7
8
namespace Del\Helper;
9
10
use Del\Image;
11
use Del\Entity\Country;
12
13
class Flag
14
{
15
    /**
16
     * @param Country $country
17
     * @param $size
18
     * @return string
19
     */
20 1
    public static function render(Country $country, $size)
21
    {
22 1
        $path = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'flags'.DIRECTORY_SEPARATOR.$size.DIRECTORY_SEPARATOR;
23 1
        $img = new Image($path.$country->getFlag());
24 1
        $header = $img->getHeader();
25
26 1
        ob_start();
27 1
        $img->output();
28 1
        $img->destroy();
29 1
        $i = ob_get_clean();
30
31 1
        return( '<img src="data:'.$header.';base64,' . base64_encode( $i ).'" />');
32
    }
33
}