Refactoring of this complex PHP method I have one complex method with 1890 paths.  I don't know how can be this refactored. Can somebody add some tips about it?  Maybe the MySQL table structure is wrong.

public function fetchClubChallengeState()
{
    $c = $this-&gt;caller-&gt;in_club;
    $o = $this-&gt;opponent-&gt;in_club;

    if (!$c || !$o) {
        return false;
    }

    $last = Yii::app()-&gt;db-&gt;createCommand()
        -&gt;select('*')
        -&gt;from('challenge')
        -&gt;where('(caller=:caller OR caller=:opponent) AND winner=0', [':caller'=&gt;$c, ':opponent'=&gt;$o])
        -&gt;limit(1)
        -&gt;queryRow();

    if ($last['caller']==$c and $last['opponent']==$o or $last['caller']==$o and $last['opponent']==$c) {
        $created = strtotime($last['created']);

        if ($this-&gt;isBetweenDates($created + 1800, $created + 3600)) {
            $this-&gt;challengeID = (int)$last['id'];
            $this-&gt;callersClubRole = $last['caller'] == $c ? 'caller' : 'opponent';
            $this-&gt;callersClub = $last['caller'] == $c ? $last['name_caller'] : $last['name_opponent'];
            $this-&gt;opponentsClubRole = $last['opponent'] == $o ? 'opponent' : 'caller';
            $this-&gt;opponentsClub = $last['opponent'] == $o ? $last['name_opponent'] : $last['name_caller'];
        }
    }
}


Edit:
The structure of the challenge table: 

CREATE TABLE `challenge` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `caller` mediumint(7) unsigned NOT NULL DEFAULT '0',
 `opponent` mediumint(7) unsigned NOT NULL DEFAULT '0',
 `name_caller` varchar(20) NOT NULL DEFAULT '',
 `name_opponent` varchar(20) NOT NULL DEFAULT '',
 `winner` tinyint(1) unsigned NOT NULL DEFAULT '0',
 `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
 //...
PRIMARY KEY (`id`),
KEY `c_o` (`caller`,`opponent`),
KEY `winner` (`winner`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;


If the challenge was started by Player1's club, that clubs ID goes to the caller field and the ID of the opponents club goes to the opponent field. These two IDs are checked here:
if ($last['caller']==$c and $last['opponent']==$o or $last['caller']==$o and $last['opponent']==$c) {
This means, that the found challenge is between the clubs of the 2 players.

The code is also here.
Don't know what happens in your db, but LIMIT 1 suggests that result of your query will return exactly what you ask or nothing. In this case no need to compare caller and opponent in if statement - just return (false) from method when $last is empty/false.

Otherwise if one caller may have more 'winner = 0' opponents LIMIT 1 could give you result that you won't use (if statement will reject it) while there's a valid one but was cut off by limit. In this case better provide full description in where clause (if statement will also check if there is any result).