Solved How to check if the string can be resolved by ItemFactory

Discussion in 'Development' started by TestDevelopment, Feb 22, 2021 at 7:53 PM.

  1. TestDevelopment

    TestDevelopment Spider

    Messages:
    12
    GitHub:
    non
    I have problems with this code:
    PHP:
    private function getId($name){
            if(!
    $name == ""){
                if(
    $this->isItem(ItemFactory::fromString($name)->getId())){
                    return 
    ItemFactory::fromString($name)->getId();
                }


            }

            return 
    0;

        }
       
    Is it somehow possible to check if the String is vaild?
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,572
    GitHub:
    muqsit
    TestDevelopment and Primus like this.
  3. TestDevelopment

    TestDevelopment Spider

    Messages:
    12
    GitHub:
    non
    Thx, but i didnt had any problems with the condition, but anyway thx
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.