Make report.

@return array
@throws Exception
332856
public function execute()
    {
        $this->unixParams();
        $output = [];
        $return_var = 0;

        exec($this->the_command, $output, $return_var);

        if ($return_var !== 0) {
            throw new Exception(
                'Your report has an error and couldn\'t be processed! Try to output the command: '.
                escapeshellcmd($this->the_command),
                1
            );
        }

        return $output;
    }
415046
public function getAllReports()
    {
        $reports = $this->getAllReportClasses();
        $cacheId = CacheId::siteAware(CacheId::languageAware('Reports' . md5(implode('', $reports))));
        $cache   = PiwikCache::getTransientCache();

        if (!$cache->contains($cacheId)) {
            $instances = array();

            /**
             * Triggered to add new reports that cannot be picked up automatically by the platform.
             * This is useful if the plugin allows a user to create reports / dimensions dynamically. For example
             * CustomDimensions or CustomVariables. There are a variable number of dimensions in this case and it
             * wouldn't be really possible to create a report file for one of these dimensions as it is not known
             * how many Custom Dimensions will exist.
             *
             * **Example**
             *
             *     public function addReport(&$reports)
             *     {
             *         $reports[] = new MyCustomReport();
             *     }
             *
             * @param Report[] $reports An array of reports
             */
            Piwik::postEvent('Report.addReports', array(&$instances));

            foreach ($reports as $report) {
                $instances[] = new $report();
            }

            /**
             * Triggered to filter / restrict reports.
             *
             * **Example**
             *
             *     public function filterReports(&$reports)
             *     {
             *         foreach ($reports as $index => $report) {
             *              if ($report->getCategory() === 'Actions') {}
             *                  unset($reports[$index]); // remove all reports having this action
             *              }
             *         }
             *     }
             *
             * @param Report[] $reports An array of reports
             */
            Piwik::postEvent('Report.filterReports', array(&$instances));

            @usort($instances, array($this, 'sort'));

            $cache->save($cacheId, $instances);
        }

        return $cache->fetch($cacheId);
    }
863585
protected function build()
    {
        $events = [];

        foreach ($this->queue as $report) {
            $event = $report->toArray();

            if ($event) {
                $events[] = $event;
            }
        }

        return [
            'apiKey' => $this->config->getApiKey(),
            'notifier' => $this->config->getNotifier(),
            'events' => $events,
        ];
    }
287983
public function GetOutput() {
        $numberOfVarsExtracted = extract($this->variablesList);
        if (count($this->variablesList) !== $numberOfVarsExtracted) {
            $errMsg = "Number of variables extracted different from the $vars array";
            throw new \Exception($errMsg, Codes\LogicErrors::UNEXPECTED_VALUE, null);
        }
        ob_start();
        include_once $this->contentFile;
        $content = ob_get_clean();
        ob_start();
        include_once "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::ViewsFolderName . \Puzzlout\Framework\Enums\FileNameConst::LayoutTemplate;
        return ob_get_clean();
    }
158493
public function create()
    {
        try {
            $schema = explode(';', str_replace(PHP_EOL, '', $this->getSchema()));
            array_pop($schema);

            # db structure
            $sql = array_shift($schema);
            $this->db->query($sql . ';');

            # indecies
            foreach($schema as $sql) {
                $this->db->query($sql . ';');
            }
        } catch(Exception $e) {
            throw new Exception($e->getMessage(), 1);
        }
    }
432733
public function farray() {
		if(is_object($this->sth)) {
			$retval = $this->sth->fetchAll();
		}
		else {
			throw new Exception(__METHOD__ .": statement handle was not created");
		}
		
		return($retval);
	}
727252
public function buildForStaff()
    {
        if (!method_exists($this, 'toStaff')) {
            throw new \Exception(__CLASS__.'未实现此方法：toStaff()');
        }

        $base = array(
                 'touser'  => $this->to,
                 'msgtype' => $this->getDefaultMessageType(),
                );
        if (!empty($this->staff)) {
            $base['customservice'] = array('kf_account' => $this->staff);
        }

        return array_merge($base, $this->toStaff());
    }
1027979
public static function getReportArray()
    {
        $composerArray = self::getComposerArray();
        $packages = self::getPackagesAndDependencies($composerArray['require']);
        $version = self::getDecomposerVersion($composerArray, $packages);

        $reportArray['Server Environment'] = self::getServerEnv();
        $reportArray['Laravel Environment'] = self::getLaravelEnv($version);
        $reportArray['Installed Packages'] = self::getPackagesArray($composerArray['require']);

        empty(self::getExtraStats()) ? '' : $reportArray['Extra Stats'] = self::getExtraStats();

        return $reportArray;
    }
1140138
public function create()
        {
            $sql = $this->generateCreateSql();
            $query = new RawQuery($sql);
            try {
                $this->drop();
                return Statement::getPreparedStatement($query)->execute();
            } catch (\Exception $e) {
                throw new Exception('Error creating table ' . $this->getB2DBName() . ': ' . $e->getMessage(), $sql);
            }
        }
582486
public function buildForReply()
    {
        if (!method_exists($this, 'toReply')) {
            throw new \Exception(__CLASS__.'未实现此方法：toReply()');
        }

        $base = array(
                 'ToUserName'   => $this->to,
                 'FromUserName' => $this->from,
                 'CreateTime'   => time(),
                 'MsgType'      => $this->getDefaultMessageType(),
                );

        return XML::build(array_merge($base, $this->toReply()));
    }
1255409
public function getFailures()
    {
        $results = [];
        foreach ($this->hash as $key) {
            if ($this->hash[$key] instanceof \Exception) {
                $results[] = $this->hash[$key];
            }
        }

        return $results;
    }
1107412
public function send()
    {
        $url = array_get($this->config, 'url');
        if (is_null($url)) {
            throw new Exception('Unable to find valid url. Please verify component configuration.');
        }


        $files = $this->getFiles();

        $token = csrf_token();


        $fields = array_merge([
            'url'         => $this->url,
            'description' => $this->description,
            'user_id'     => auth()->user()->id,
            'brand_id'    => app('antares.memory')->make('primary')->get('brand.default'),
            '_token'      => $token], $files);


        $headers[] = 'X-CSRF-Token:' . $token;



        $ch     = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        curl_close($ch);
        $this->cleanup($files);
        if (!$this->isJsonResponse($result)) {
            throw new Exception('Unable to send exception details to support system.');
        }
        $response = json_decode($result);

        if (isset($response->id) && (int) $response->id <= 0) {
            throw new Exception('Unable to send exception details to support system.');
        }
        return $this;
    }
688934
public function getReports()
    {
        $reports = array();
        $dir = ini_get("xhprof.output_dir");

        if (is_dir($dir)) {
            $finder = new Finder();
            $finder
                ->files()
                ->name('*.'.$this->namespace)
                ->notName($this->id.'.'.$this->namespace)
                ->in($dir)
                ->sort(function (SplFileInfo $a, SplFileInfo $b) {
                    return strcmp($b->getRealpath(), $a->getRealpath());
                })
            ;

            foreach ($finder as $runFile) {
                $infos = explode('.', basename($runFile));
                $runId = array_shift($infos);

                $reports[] = $this->getReport($runId);

                if (count($reports) > 5) {
                    break;
                }
            }
        }

        return $reports;
    }
192604
public function toArray()
    {
        $hasChainedException = PHP_VERSION_ID >= 50300;

        $exception = $this->exception;

        do {
            $whoops = $this->getWhoopsRunner();
            $whoops->pushHandler(new WhoopsHandler($this->config))->register();

            $exceptions[] = json_decode(
                $whoops->handleException($exception),
                true
            );
        } while ($hasChainedException && $exception = $exception->getPrevious());

        $data = [
            'title' => get_class($this->exception),
            'message' => $this->exception->getMessage(),
            'exception' => [
                'file' => $this->exception->getFile(),
                'line' => $this->exception->getLine(),
                'code' => $this->exception->getCode(),
            ],
            'platform' => 'php',
            'environment' => $this->config->getEnvironment(),
            'events' => [
                'exceptions' => $exceptions,
                'meta_data' => $this->config->getMetaData(),
                'user' => $this->config->getUser(),
                'sdk' => $this->config->getSdk(),
            ],
        ];

        if (empty($data['level'])) {
            if (method_exists($exception, 'getSeverity')) {
                $data['level'] = $this->translateSeverity($exception->getSeverity());
            } else {
                $data['level'] = self::ERROR;
            }
        }

        return $data;
    }
442232
public function getMessage(): array
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        try {
            $message = XML::parse(strval($this->app['request']->getContent()));
        } catch (\Throwable $e) {
            throw new Exception('Invalid request XML: '.$e->getMessage(), 400);
        }

        if (!is_array($message) || empty($message)) {
            throw new Exception('Invalid request XML.', 400);
        }

        if ($this->check) {
            $this->validate($message);
        }

        return $this->message = $message;
    }
654808
public function update()
    {
        $data = $this->client->get('http://dev.maxmind.com/static/csv/codes/country_continent.csv');

        // Verify server response
        if ($this->client->getErrors() !== null) {
            throw new Exception($this->client->getErrors());
        }

        $lines = explode("\n", $data[0]);

        array_shift($lines);

        $output = [];

        foreach ($lines as $line) {
            $arr = str_getcsv($line);

            if (count($arr) < 2) {
                continue;
            }

            $output[$arr[0]] = $arr[1];
        }

        // Get path
        $path = $this->config('continent_path');

        file_put_contents($path, json_encode($output));

        return "Continent file ({$path}) updated.";
    }
236899
public function createAttributeValueFromRequest()
    {
        $data = $this->post();
        if (!is_array($data)) {
            $data = [];
        }
        $data += [
            'operation' => null,
            'current-token' => '',
            'current-token-hash' => '',
        ];
        switch ($data['operation']) {
            case 'keep':
                $value = $data['current-token'];
                if (!is_string($value)) {
                    $value = '';
                }
                if ($value !== '') {
                    if (sha1($this->getSessionHash(false) . $value) !== $data['current-token-hash']) {
                        $ok = false;
                    } else {
                        $ok = $this->app->make(Token::class)->isGenerated($value);
                    }
                    if (!$ok) {
                        throw new Exception('Hack attempt detected.');
                    }
                }
                break;
            case 'generate':
                $value = $this->app->make(Token::class)->generate();
                break;
            case 'remove':
                $value = '';
                break;
            default:
                throw new Exception('Invalid operation');
        }

        return $this->createAttributeValue($value);
    }