Passed
Push — main ( eb8d0e...0b1fab )
by Rafael
52:51
created

Images::getLogo()   B

Complexity

Conditions 8
Paths 6

Size

Total Lines 32
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 13
nc 6
nop 5
dl 0
loc 32
rs 8.4444
c 1
b 0
f 0
1
<?php
2
3
namespace Dolibarr\Lib;
4
5
abstract class Images
6
{
7
    /**
8
     * Gets the path of the logo.
9
     *
10
     * @param string $theme
11
     * @param int $width
12
     * @param string $logo_small
13
     * @param string $logo
14
     * @param bool $only_company
15
     *
16
     * @return string|false
17
     */
18
    public static function getLogo(string $theme, int &$width, string $logo_small = '', string $logo = '', bool $only_company = false)
19
    {
20
        // Define company logo directory
21
        $companyOutDir = constant('DOL_DATA_ROOT') . '/mycompany';
22
23
        // Check for small logo in thumbs directory
24
        if (!empty($logo_small) && is_readable($companyOutDir . '/logos/thumbs/' . $logo_small)) {
25
            return constant('BASE_URL') . '/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file=' . urlencode('logos/thumbs/' . $logo_small);
26
        }
27
28
        // Check for main logo in logos directory
29
        if (!empty($logo) && is_readable($companyOutDir . '/logos/' . $logo)) {
30
            $width = 128;
31
            return constant('BASE_URL') . '/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file=' . urlencode('logos/' . $logo);
32
        }
33
34
        if ($only_company) {
35
            return false;
36
        }
37
38
        // Check for theme specific logo
39
        if (is_readable(constant('DOL_DOCUMENT_ROOT') . '/theme/' . $theme . '/img/alixar_rectangular_logo.svg')) {
40
            return constant('BASE_URL') . '/theme/' . $theme . '/img/alixar_rectangular_logo.svg';
41
        }
42
43
        // Check for default logo
44
        if (is_readable(constant('DOL_DOCUMENT_ROOT') . '/theme/common/alixar_rectangular_logo.svg')) {
45
            return constant('BASE_URL') . '/theme/common/alixar_rectangular_logo.svg';
46
        }
47
48
        // Return default padlock logo if no other logo is found
49
        return constant('BASE_URL') . '/theme/common/login_logo.png';
50
    }
51
}
52