Check if two models have the same values in all properties.

@param ModelInterface $firstModel  The first model to compare.
@param ModelInterface $secondModel The second model to compare.

@return boolean True - If both models are same, false if not.
6159
public function sameModels($firstModel, $secondModel)
    {
        foreach ($firstModel as $key => $value) {
            if ($key === $this->idProperty) {
                continue;
            }

            if (\is_array($value)) {
                if (!\is_array($secondModel->getProperty($key))) {
                    return false;
                }

                if (\serialize($value) !== \serialize($secondModel->getProperty($key))) {
                    return false;
                }
            } elseif ($value !== $secondModel->getProperty($key)) {
                return false;
            }
        }

        return true;
    }
1218704
static public function same($value, $value2, $message = null, $propertyPath = null)
        {
            if ($value !== $value2) {
                $message = $message ?: sprintf(
                    'Value "%s" is not the same as expected value "%s".',
                    static::stringify($value),
                    static::stringify($value2)
                );

                throw static::createException($value, $message, static::INVALID_SAME, $propertyPath, array('expected' => $value2));
            }
        }
497714
public static function hasModel($shortName, $instaitiateOnTrue = false)
    {
        $models = static::models();
        if (isset($models[$shortName])) {
            if ($instaitiateOnTrue) {
                $className = $models[$shortName];
                return $className::model();
            } else {
                return true;
            }
        }
        return false;
    }
1137846
public function sameValueAs(ValueObjectInterface $dateTimeWithTimeZone)
    {
        if (false === Util::classEquals($this, $dateTimeWithTimeZone)) {
            return false;
        }

        return $this->getDateTime()->sameValueAs($dateTimeWithTimeZone->getDateTime()) &&
            $this->getTimeZone()->sameValueAs($dateTimeWithTimeZone->getTimeZone());
    }
1116148
public function comp(MoneyInterface $first, MoneyInterface $second)
    {
        $this->resolveCurrency($first, $second);
        return $this->math->comp($first->getAmount(), $second->getAmount());
    }
157302
public function first()
    {
        // Perform query
        $result = $this->get();

        // Abort if no models where found
        if (!$result || !is_array($result) || empty($result)) {
            return false;
        }

        // Return the first matching model
        return reset($result);
    }
2194
function(model, options) {
      options || (options = {});
      model = this._prepareModel(model, options);
      if (!model) return false;
      var already = this.getByCid(model) || this.get(model);
      if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
      this._byId[model.id] = model;
      this._byCid[model.cid] = model;
      var index = options.at != null ? options.at :
                  this.comparator ? this.sortedIndex(model, this.comparator) :
                  this.length;
      this.models.splice(index, 0, model);
      model.bind('all', this._onModelEvent);
      this.length++;
      if (!options.silent) model.trigger('add', model, this, options);
      return model;
    }
1189404
protected function modelExists()
    {
        $model = $this->option('model');

        if (empty($model)) {
            return true;
        }

        return class_exists($model) && is_subclass_of($model, Model::class);
    }
798740
private function isRootModel(ModelInterface $model)
    {
        return (null !== $this->rootCondition) && $this->rootCondition->matches($model);
    }
650194
protected function checkIfEntityExists()
    {
        $query = new ReadQuery($this->connection, $this->model, $this->factory, $this->accessor, $this->dispatcher);

        foreach ($this->model->primaryFields() as $field) {
            $value = $this->accessor->getPropertyValue($this->instance, $field->name());

            if ($value === null) {
                return false;
            }

            $query->where($field->name(), $value, '=', 'and');
        }

        return $query->count() > 0;
    }
1138617
public function equals($o1, $o2)
    {
        // TODO: handle objects that don't match the schema
        foreach ($this->_props as $key=>$prop) {
            if(!$prop->type->equals($o1->get($key), $o2->get($key)))

                return false;
        }

        return true;
    }
532848
public function equals(PrincipalInterface $another)
    {

        // query whether or not another principal has been passed
        if ($another instanceof PrincipalInterface) {
            $anotherName = $another->getName();
            $equals = false;
            if ($this->name == null) {
                $equals = $anotherName == null;
            } else {
                $equals = $this->name->equals($anotherName);
            }

            // return the flag if the both are equal
            return $equals;
        }

        // return FALSE if they are not equal
        return false;
    }
527920
public function isEqualByInstance(CollectionInstanceInterface $instance_in)
    {
        $this->rewind();
        while (!empty($this->current())) {
            if ($this->hasEqualArrays($this->current()->toArray(), $instance_in->toArray())) {
                return true;
            }
            $this->next();
        }
        $this->rewind();
        return false;
    }
1239238
protected function isModelDeletable(Model $model)
    {
        $this->lastUnmetDeleteConditionMessage = null;

        // access rights
        if ( ! $this->isAuthorizedToDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForAuthorizationFailure();
            return false;
        }

        // delete condition & model configuration
        $info = $this->getModelInformation();

        if ( ! $info->allowDelete()) {
            $this->lastUnmetDeleteConditionMessage = $this->getUnmetConditionMessageForDisallowedFailure();
            return false;
        }

        $condition = $info->deleteCondition();

        if ( ! $condition) {
            return true;
        }

        // Resolve condition and check.
        $strategies = $this->interpretDeleteCondition($condition);

        foreach ($strategies as $strategy => $parameters) {

            /** @var DeleteConditionStrategyFactoryInterface $factory */
            $factory = app(DeleteConditionStrategyFactoryInterface::class);
            $strategy = $factory->make($strategy);

            if ( ! $strategy->check($model, $parameters)) {
                $this->lastUnmetDeleteConditionMessage = $strategy->message();
                return false;
            }
        }

        return true;
    }
743503
public static <T> boolean isEqual(final T first, final T second) {
        /* test to see if they are both null, or both reference the same object */
        if (first == second) return true;

        if (first == null && second != null) return false;

        return first.equals(second);
    }
522466
public function isSubsetOf($collection)
    {
        /** @var ModelInterface $localModel */
        foreach ($this as $localModel) {
            /** @var ModelInterface $otherModel */
            foreach ($collection as $otherModel) {
                if (($localModel->getProviderName() === $otherModel->getProviderName())
                    && ($localModel->getId() === $otherModel->getId())
                ) {
                    continue;
                }
                return false;
            }
        }
        return true;
    }
662175
public function isUnique(TranslationModel $translationModel)
    {
        $qb = $this->createQueryBuilder('t');
        $count = $qb->select('COUNT(t.id)')
            ->where('t.domain = :domain')
            ->andWhere('t.keyword = :keyword')
            ->setParameter('domain', $translationModel->getDomain())
            ->setParameter('keyword', $translationModel->getKeyword())
            ->getQuery()
            ->getSingleScalarResult();

        return $count == 0;
    }