Test Setup Failed
Pull Request — latest (#3)
by Mark
34:22
created

ExtensionRequiredLibraryException::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
c 1
b 0
f 1
dl 0
loc 13
rs 10
cc 3
nc 4
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UnicornFail\Emoji\Exception;
6
7
class ExtensionRequiredLibraryException extends \RuntimeException implements EmojiException
8
{
9
    public function __construct(string $library, ?object $object = null, ?\Throwable $previous = null)
10
    {
11
        $class = $object
12
            ? \get_class($object)
13
            : false;
14
15
        if ($class !== false) {
16
            $message = \sprintf("%s requires the following library to be installed:\n\ncomposer require %s\n\n", $class, $library);
17
        } else {
18
            $message = \sprintf("The following library is required to be installed:\n\ncomposer require %s\n\n", $library);
19
        }
20
21
        parent::__construct($message, 0, $previous);
22
    }
23
}
24