for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @package WPEmerge
* @author Atanas Angelov <[email protected]>
* @copyright 2018 Atanas Angelov
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
* @link https://wpemerge.com/
*/
namespace WPEmerge\Routing\Conditions;
use WPEmerge\Requests\RequestInterface;
* Check against the current ajax action.
class AdminCondition implements ConditionInterface {
* Menu slug.
*
* @var string
protected $menu = '';
* Parent menu slug.
protected $parent_menu = '';
* Constructor
* @codeCoverageIgnore
* @param string $menu
* @param string $parent_menu
public function __construct( $menu, $parent_menu = '' ) {
$this->menu = $menu;
$this->parent_menu = $parent_menu;
}
* {@inheritDoc}
public function isSatisfied( RequestInterface $request ) {
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
return false;
return get_current_screen()->id === get_plugin_page_hookname( $this->menu, $this->parent_menu );
get_current_screen()
null
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
public function getArguments( RequestInterface $request ) {
return ['hook' => get_plugin_page_hookname( $this->menu, $this->parent_menu )];
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.