Completed
Push — master ( a17288...aa8e2a )
by Derek Stephen
01:49
created

Flag::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
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
    public static function render(Country $country, $size)
21
    {
22
        $path = dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'flags'.DIRECTORY_SEPARATOR.$size.DIRECTORY_SEPARATOR;
23
        $img = new Image($path.$country->getFlag());
24
        $header = $img->getHeader();
25
26
        ob_start();
27
        $img->output();
28
        $img->destroy();
29
        $i = ob_get_clean();
30
31
        return( '<img src="data:'.$header.';base64,' . base64_encode( $i ).'" />');
32
    }
33
}