xAPI-vle/moodle-logstore_xapi

View on GitHub
src/transformer/events/debug/debug_event.php

Summary

Maintainability
A
1 hr
Test Coverage
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
 
/**
* Generic Debug Transform
*
* @package logstore_xapi
* @copyright Milt Reder <milt@yetanalytics.com>
* Cliff Casey <cliff@yetanalytics.com>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
 
namespace src\transformer\events\debug;
 
use src\transformer\utils as utils;
 
/**
* Transformer for Any Event to emit debug xAPI statements.
* Only used in development.
*
* @param array $config The transformer config settings.
* @param \stdClass $event The event to be transformed.
* @return array
*/
Method `debug_event` has 27 lines of code (exceeds 25 allowed). Consider refactoring.
function debug_event(array $config, \stdClass $event) {
//debug
$repo = $config['repo'];
if (isset($event->objecttable) && isset($event->objectid) && ($event->action !== 'deleted' || $event->crud !== 'd')) {
$event_object = $repo->read_record_by_id($event->objecttable, $event->objectid);
} else {
$event_object = array();
}
 
return [[
'object' => [
'id' => 'http://www.yetanalytics.com/test_events/debug' . utils\reverseBackslashes($event->eventname)
],
'actor' => [
'mbox' => 'mailto:tester@example.com'
],
'verb' => [
'id' => 'http://www.yetanalytics.com/debug',
'display' => [
'en-US' => 'debug'
],
],
'context' => [
'extensions' => [
'http://www.yetanalytics.com/debug_objects/event' => $event,
'http://www.yetanalytics.com/debug_objects/event_other' => unserialize($event->other),
'http://www.yetanalytics.com/debug_objects/event_object' => $event_object
]
]
]];
}