Reads data for an event.
@param [String => Mixed] $opts
@return [String => Mixed]
@override Event
6579
public function read(array $opts) {
        $statement = array_merge_recursive(parent::read($opts), [
            'verb' => [
                'id' => 'http://adlnet.gov/expapi/verbs/attended',
                'display' => $this->readVerbDisplay($opts),
            ],
            'object' => [
                'id' => $opts['session_url'],
                'definition' => [
                    'type' => $opts['session_type'],
                    'name' => [
                        $opts['context_lang'] => $opts['session_name'],
                    ],
                    'description' => [
                        $opts['context_lang'] => $opts['session_description'],
                    ]
                ],
            ],
            'result' => [
                'duration' => $opts['attempt_duration'],
                'completion' => $opts['attempt_completion']
            ],
            'context' => [
                'instructor' => $this->readUser($opts, 'user'),
                'contextActivities' => [
                    'grouping' => [
                        $this->readCourse($opts),
                    ],
                    'parent' => [
                        $this->readModule($opts),
                    ],
                    'category' => [
                        [
                            'id' => 'http://xapi.trainingevidencesystems.com/recipes/attendance/0_0_1#simple',
                            'definition' => [
                                'type' => 'http://id.tincanapi.com/activitytype/recipe'
                            ]
                        ]
                    ],
                ],
            ],
        ]);

        // Overwrite actor, don't merge it. 
        $statement['actor'] = $this->readUser($opts, 'attendee');

        return $statement;
    }
451725
public function read(array $opts) {

        $scoreRaw = (float) ($opts['grade']->grade ?: 0);
        $scoreMin = (float) ($opts['grade_items']->grademin ?: 0);
        $scoreMax = (float) ($opts['grade_items']->grademax ?: 0);
        $scorePass = (float) ($opts['grade_items']->gradepass ?: null);
        $success = false;
        //if there is no passing score then success is unknown.
        if ($scorePass == null) {
            $success = null;
        }
        elseif ($scoreRaw >= $scorePass) {
            $success = true;
        }
        //Calculate scaled score as the distance from zero towards the max (or min for negative scores).
        $scoreScaled;
        if ($scoreRaw >= 0) {
            $scoreScaled = $scoreRaw / $scoreMax;
        }
        else
        {
            $scoreScaled = $scoreRaw / $scoreMin;
        }

        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'assignment_graded',
            'graded_user_id' => $opts['graded_user']->id,
            'graded_user_url' => $opts['graded_user']->url,
            'graded_user_name' => $opts['graded_user']->fullname,
            'grade_score_raw' => $scoreRaw,
            'grade_score_min' => $scoreMin,
            'grade_score_max' => $scoreMax,
            'grade_score_scaled' => $scoreScaled,
            'grade_success' => $success,
            'grade_completed' => true,
            'grade_comment' => strip_tags($opts['grade_comment']),
        ])];
    }
1361718
public function getError($error, $opts=array()) {
		if (is_array($error) && isset($error['filter'])) {
			return $this->getErrorMessage($error['filter'], $error+$opts);
		} elseif (is_int($error)) {
			return $this->getErrorMessage($error, $opts);
		} else {
			return $this->getErrorMessage(0, $opts);
		}
	}
861349
public static function show(array $data, array $opts = []): void
    {
        static $counter = 0;
        static $started = 1;

        if ($started) {
            $started = 0;
            $opts    = \array_merge([
                // 'char' => Cli::isSupportColor() ? '─' : '-', // ——
                'char'        => '-',
                'prefix'      => Cli::isSupportColor() ? '├' : '|',
                'leftPadding' => '',
            ], $opts);

            $opts['_level']   = 1;
            $opts['_is_main'] = true;

            Console::startBuffer();
        }

        foreach ($data as $key => $value) {
            if (\is_scalar($value)) {
                $counter++;
                $leftString = $opts['leftPadding'] . \str_pad($opts['prefix'], $opts['_level'] + 1, $opts['char']);

                Console::write($leftString . ' ' . FormatUtil::typeToString($value));
            } elseif (\is_array($value)) {
                $newOpts             = $opts;
                $newOpts['_is_main'] = false;
                $newOpts['_level']++;

                self::show($value, $newOpts);
            }
        }

        if ($opts['_is_main']) {
            Console::write('node count: ' . $counter);
            // var_dump('f');
            Console::flushBuffer();

            // reset.
            $counter = $started = 0;
        }
    }
96496
public function stringifyOpts($opts)
	{
		$pairs = array();
		foreach ($opts as $k => $v) {
			if (is_null($v)) {
				continue;
			}
			if ($v === true) {
				$pairs[] = $k;
			} elseif ($v === false) {
				$pairs[] = $k.'=false';
			} else {
				$pairs[] = $k.'='.$v;
			}
		}
		return implode(' ', $pairs);
	}
295404
public function insertEvent($event, $optParams = []): Google_Service_Calendar_Event
    {
        if ($event instanceof Event) {
            $event = $event->googleEvent;
        }

        return $this->calendarService->events->insert($this->calendarId, $event, $optParams);
    }
797259
public function fromArray(array $opts) 
    {
        $this->_opts = \Coast\array_merge_smart(
            $this->_opts,
            $opts
        );
        return $this;
    }
605667
function readStream(opts) {
    return db.createReadStream(ns.encodeRange(opts)).pipe(decodeStream(opts))
  }
976255
protected function executeWebhook(array $opts, array $files) {
        return $this->client->apimanager()->endpoints->webhook->executeWebhook($this->id, $this->token, $opts, $files, array('wait' => true))->then(function ($data) {
            $channel = $this->client->channels->get($this->channelID);
            if($channel instanceof \CharlotteDunois\Yasmin\Interfaces\TextChannelInterface) {
                return $channel->_createMessage($data);
            }
            
            return $data;
        });
    }
865280
public function read(array $opts) {
        return [array_merge(parent::read($opts)[0], [
            'recipe' => 'course_completed',
            'user_id' => $opts['relateduser']->id,
            'user_url' => $opts['relateduser']->url,
            'user_name' => $opts['relateduser']->fullname,
        ])];
    }
1058020
public function retrieveData($path, array $params = array(), array $opts = array())
    {
        return empty($params)
            ? $this->_processResponse($this->http->get($this->_getApiPath($opts) . $path))
            : $this->_processResponse(
                $this->http->get($this->_getApiPath($opts) . $path . "?" . http_build_query($params, '', '&'))
            );
    }
716681
protected function _processString($str, $opts)
    {
        if (!empty($opts['length'])) {
            return substr($str, empty($opts['start']) ? 0 : $opts['start'], $opts['length']);
        } elseif (!empty($opts['start'])) {
            return substr($str, $opts['start']);
        }

        return $str;
    }
1319569
public function find($opts = [])
    {
        empty($opts['table']) && $opts['table'] = $this->table;

        $obj = new \wf\db\Finder($opts);
        $obj->setDb($this->getDb());

        return $obj;
    }
975268
public static function all($params = null, $opts = null)
    {
        self::_validateParams($params);
        $url = static::classUrl();

        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
        if (!is_a($obj, 'Stripe\\Collection')) {
            $class = get_class($obj);
            $message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
            throw new \Stripe\Error\Api($message);
        }
        $obj->setLastResponse($response);
        $obj->setRequestParams($params);
        return $obj;
    }
905501
public static function curl(array $opts = [])
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        foreach ($opts as $key => $value) {
            curl_setopt($ch, $key, $value);
        }

        $response = curl_exec($ch);
        $request = $response !== false;
        if (!$request) {
            $response = curl_getinfo($ch);
        }
        curl_close($ch);

        return compact('request', 'response');
    }
280062
public function curl($opts){
        $apiAccessToken = $this->getApiAccessToken();
        $apiEndPoint = $this->getApiEndPoint();
        $headers = array(
            'Authorization' => 'bearer ' . $apiAccessToken 
        );
        $defaultOpts = [
            'url' => '',
            'method' => 'get',
            'timeout' => 1,
            'uri' => $apiEndPoint,
            'path' => '',
            'data' => [],
            'headers' => $headers,
        ];
        $opts = array_merge($defaultOpts, $opts);

        $url = $opts['url'] ? : $opts['uri'] . $opts['path'];
        $curl = new Curl();
        $curl->setHeaders($opts['headers']);
        $curl->setRetry(1);
        $curl->setTimeout($opts['timeout']);
        if($opts['method'] == 'get'){
            $curl->get($url, $opts['data']);
        }else if($opts['method'] == 'post'){
            $curl->post($url, $opts['data']);
        }

        if ($curl->error) {
            return false;
        } else {
            return $curl->response;
        }
    }
149043
public static function upcoming($params = null, $opts = null)
    {
        $url = static::classUrl() . '/upcoming';
        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
        $obj = Util\Util::convertToStripeObject($response->json, $opts);
        $obj->setLastResponse($response);
        return $obj;
    }