src/Shared/Message/Mapping/MappingTrait.php
protected static function getTemplateByCode(
        /*# int */ $code,
        /*# string */ $class
    )/*# : string */ {
        // default template, last resort
        if (__CLASS__ === $class) {
            return "unknown message code: $code, %s";
        }

        // check $class
        if ($class::messageDefined($code)) {
            // load message mapping for $class
            $class::loadMappings();

            // get the message template
            return $class::getMessage($code);
        }

        // search upwards
        return self::getTemplateByCode($code, get_parent_class($class));
    }
protected static function getTemplateByCode(
        /*# int */ $code,
        /*# string */ $class
    )/*# : string */ {
        // default template, last resort
        if (__CLASS__ === $class) {
            return "unknown message code: $code, %s";
        }

        // check $class
        if ($class::messageDefined($code)) {
            // load message mapping for $class
            $class::loadMappings();

            // get the message template
            return $class::getMessage($code);
        }

        // search upwards
        return self::getTemplateByCode($code, get_parent_class($class));
    }
Resolving $code to message template, start from $class

@param  int $code message code
@param  string $class class name
@return string
@access protected