I'm just curious, why is onlyOwner and _checkOwner divided into two places? I was looking into '@openzeppelin/contracts/access/Ownable.sol' to better understand how this contract works. I also saw similar pattern in another @openzeppelin contracts so I like to know what is reason behind this structure.
Code to reproduce
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}