in below post my answer got's deleted.
The accepted answer gets updated after my post so how you guys consider my answer as copied
You can see here in revision history https://magento.stackexchange.com/posts/226913/revisions
And for further note I checked that method in core and then answer
In above file I checked
getIdByCode method and answered as its require two params