Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 46... Línea 46...
46
     *
46
     *
47
     * @param string $value a valid IRI value or any string
47
     * @param string $value a valid IRI value or any string
48
     * @param string|null $type if none passed $type will be 'element'
48
     * @param string|null $type if none passed $type will be 'element'
49
     * @return string a valid IRI value
49
     * @return string a valid IRI value
50
     */
50
     */
51
    public static function generate(string $value, string $type = null): string {
51
    public static function generate(string $value, ?string $type = null): string {
52
        if (self::check($value)) {
52
        if (self::check($value)) {
53
            return $value;
53
            return $value;
54
        }
54
        }
55
        if (empty($type)) {
55
        if (empty($type)) {
56
            $type = 'element';
56
            $type = 'element';
Línea 67... Línea 67...
67
     *
67
     *
68
     * @param string $value the currewnt IRI value.
68
     * @param string $value the currewnt IRI value.
69
     * @param string|null $type if $value is a fake IRI, the $type must be provided.
69
     * @param string|null $type if $value is a fake IRI, the $type must be provided.
70
     * @return string the original value used in iri::generate.
70
     * @return string the original value used in iri::generate.
71
     */
71
     */
72
    public static function extract(string $value, string $type = null): string {
72
    public static function extract(string $value, ?string $type = null): string {
73
        if (empty($type)) {
73
        if (empty($type)) {
74
            $type = 'element';
74
            $type = 'element';
75
        }
75
        }
76
        $xapibase = (new moodle_url("/xapi/$type/"))->out(false);
76
        $xapibase = (new moodle_url("/xapi/$type/"))->out(false);
77
        if (strpos($value, $xapibase) === 0) {
77
        if (strpos($value, $xapibase) === 0) {