for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @package Redcore
* @subpackage Api
*
* @copyright Copyright (C) 2008 - 2021 redWEB.dk. All rights reserved.
* @license GNU General Public License version 2 or later, see LICENSE.
*/
defined('JPATH_BASE') or die;
* Api Helper class for overriding default methods
* @subpackage Api Helper
* @since 1.8
class RApiHalHelperSiteContent
{
* Service for creating content.
* @param string $data content
* @return boolean True on success. False otherwise.
public function save($data)
if (version_compare(JVERSION, '3.0', 'lt')) {
JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table');
}
$data = (object) $data;
$article = JTable::getInstance('content');
$article->title = $data->title;
title
// $article->alias = JFilterOutput::stringURLSafe(time());
$article->alias = JFilterOutput::stringURLSafe($data->title);
$article->introtext = '<p>'.$data->description.'</p>';
$article->created = JFactory::getDate()->toSQL();;
$article->created_by_alias = $data->user;
created_by_alias
JTable
$article->state = 1;
$article->access = 1;
access
$article->metadata = '{"page_title":"'.$data->title.'","author":"'.$data->user.'","robots":""}';
$article->language = '*';
language
// $article->catid = 1;
if (!$article->check()) {
throw new Exception($article->getError());
JObject::getError()
If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated annotation
ignore-deprecated
throw new Exception(/** @scrutinizer ignore-deprecated */ $article->getError());
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
return FALSE;
return FALSE
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
return false
if (!$article->store(TRUE)) {