original_string: public function validateContract($class, $contract)
      {
          $validateObject = function ($object) {
              //does need trigger when calling *_exists with object
              $condition = is_string($object) ? class_exists($object) || interface_exists($object) : is_object($object);
              if (false === $condition) {
                  $this->throwException(new \InvalidArgumentException('Class not exists ' . $object));
              }
          };
  
          $convertClassToString = function ($object) {
              if (is_object($object)) {
                  $object = get_class($object);
              }
  
              return is_string($object) ? $object : false;
          };
  
          $validateObject($class);
          $validateObject($contract);
  
          if (!($class instanceof $contract)) {
  
              if (is_object($class)) {
                  $class = get_class($class);
              }
              $this->throwException(new \LogicException($convertClassToString($class) . ' needs to be an instance of ' . $convertClassToString($contract)));
          }
  
          return $class;
      }
code: public function validateContract($class, $contract)
      {
          $validateObject = function ($object) {
              //does need trigger when calling *_exists with object
              $condition = is_string($object) ? class_exists($object) || interface_exists($object) : is_object($object);
              if (false === $condition) {
                  $this->throwException(new \InvalidArgumentException('Class not exists ' . $object));
              }
          };
  
          $convertClassToString = function ($object) {
              if (is_object($object)) {
                  $object = get_class($object);
              }
  
              return is_string($object) ? $object : false;
          };
  
          $validateObject($class);
          $validateObject($contract);
  
          if (!($class instanceof $contract)) {
  
              if (is_object($class)) {
                  $class = get_class($class);
              }
              $this->throwException(new \LogicException($convertClassToString($class) . ' needs to be an instance of ' . $convertClassToString($contract)));
          }
  
          return $class;
      }
code_tokens: public function validateContract ( $ class , $ contract ) { $ validateObject = function ( $ object ) { //does need trigger when calling *_exists with object $ condition = is_string ( $ object ) ? class_exists ( $ object ) || interface_exists ( $ object ) : is_object ( $ object ) ; if ( false === $ condition ) { $ this -> throwException ( new \ InvalidArgumentException ( 'Class not exists ' . $ object ) ) ; } } ; $ convertClassToString = function ( $ object ) { if ( is_object ( $ object ) ) { $ object = get_class ( $ object ) ; } return is_string ( $ object ) ? $ object : false ; } ; $ validateObject ( $ class ) ; $ validateObject ( $ contract ) ; if ( ! ( $ class instanceof $ contract ) ) { if ( is_object ( $ class ) ) { $ class = get_class ( $ class ) ; } $ this -> throwException ( new \ LogicException ( $ convertClassToString ( $ class ) . ' needs to be an instance of ' . $ convertClassToString ( $ contract ) ) ) ; } return $ class ; }
docstring: Validates that class is instance of contract
  
  @param $class
  @param $contract
  
  @return string|object
  
  @throws \InvalidArgumentException|\LogicException
docstring_tokens: Validates that class is instance of contract