Checks for existance of value in attribute

@param array  $values values to check
@param string $attr   attribute name

@access protected
@return boolean
496898
protected function checkAttr($values, $attr)
    {
        if (!is_array($values)) $values = array($values);

        foreach ($values as $value) {
            if (!@in_array($value, $this->get_value($attr, 'all'))) {
                return false;
            }
        }
        return true;
    }
406038
public function addAttr($attr, $val)
    {
        if (is_string($attr) === false) {
            throw new \InvalidArgumentException;
        }

        $this->attributes[$attr] = $val;

        return $this;
    }
180245
protected function initializeProductMediaGalleryValue(array $attr)
    {

        // load the value/store/parent ID
        $valueId = $attr[MemberNames::VALUE_ID];
        $storeId = $attr[MemberNames::STORE_ID];
        $entityId = $attr[MemberNames::ENTITY_ID];

        // query whether the product media gallery value already exists or not
        if ($entity = $this->loadProductMediaGalleryValue($valueId, $storeId, $entityId)) {
            return $this->mergeEntity($entity, $attr);
        }

        // simply return the attributes
        return $attr;
    }
1180623
private function _set_session($attr){
    if ( $this->session->has(self::$sn) ){
      $args = \func_get_args();
      if ( (\count($args) === 2) && \is_string($args[0]) ){
        $attr = [$args[0] => $args[1]];
      }
      foreach ( $attr as $key => $val ){
        if ( \is_string($key) ){
          $this->session->set($val, self::$sn, $key);
        }
      }
    }
    return $this;
  }
339033
private function isValueValid(array $values): bool
    {
        foreach ($values as $value) {
            if (\preg_match("/[^\t\r\n\x20-\x7e\x80-\xfe]|\r\n/", $value)) {
                return false;
            }
        }

        return true;
    }
804544
protected function isRelationAttr($attr)
    {
        $relation = Db::parseName($attr, 1, false);

        if (method_exists($this, $relation) && !method_exists('think\Model', $relation)) {
            return $relation;
        }

        return false;
    }
1294049
public function validateIn($attribute, $value, $parameters)
    {
        if (is_array($value) && $this->hasRule($attribute, 'Array')) {
            foreach ($value as $element) {
                if (is_array($element)) {
                    return false;
                }
            }

            return count(array_diff($value, $parameters)) === 0;
        }

        return ! is_array($value) && in_array((string) $value, $parameters);
    }
306086
public function setAttribute( $attr, $value ) {
        //value is the text node
        //we add this for the sake of consistency amongst other form elements
        if( strtolower( $attr ) == 'value' ) {
           $this->setText( $value );
        } else {
            parent::setAttribute( $attr, $value );
        }
    }
1190907
function _updateAttrArray(&$attr1, $attr2)
    {
        if (!is_array($attr2)) {
            return false;
        }
        foreach ($attr2 as $key => $value) {
            $attr1[$key] = $value;
        }
    }
384889
protected function addAttrRecurses($key, array $attr)
    {
        if (isset($this->form[ $key ])) {
            $this->form[ $key ][ 'attr' ] = $this->merge_attr($this->form[ $key ][ 'attr' ], $attr);

            return true;
        }

        foreach ($this->form as $input) {
            if ($input[ 'type' ] != 'group') {
                continue;
            }

            if ($input[ 'subform' ]->addAttrRecurses($key, $attr)) {
                return true;
            }
        }

        return false;
    }
74553
function getAttribute($attr)
    {
        $attr = strtolower($attr);
        if (isset($this->_attributes[$attr])) {
            return $this->_attributes[$attr];
        }
        return null;
    }
52813
private function _changedAttribute($attr) 
    {
        preg_match('/(\w+)_(change|changed|was)$/', $attr, $matches);
        if (sizeof($matches) < 1) {
            return null;
        }

        $attr = $matches[1];
        $meth = $matches[2];
        $cur  = $this->get($attr);
        $old  = $this->get($attr, false);

        if ($meth == "was") {
            return $old;
        }
        if ($meth == "changed") {
            return $cur!=$old;
        }
        if ($meth == "change") {
            return array($old, $cur);
        }
        return null;
    }
657908
public function getAttribute($attr)
    {
        return isset($this->attributes[$attr]) ? $this->attributes[$attr] : null;
    }
1289778
public function hasValidator($validators, $attribute)
    {
        $validators = is_array($validators) ? $validators : [$validators];

        foreach ($this->rules() as $rule){
            $attributes = is_array($rule[0]) ? $rule[0] : [$rule[0]];
            if(in_array($attribute, $attributes) && in_array($rule[1], $validators)){
                return true;
            }
        }

        return false;
    }
99733
public static function validates($attr, $validation) 
    {
        $cls = get_called_class();

        if (!array_key_exists($cls, self::$_validations)) {
            self::$_validations[$cls] = array();
        }

        if (!array_key_exists($attr, self::$_validations[$cls])) {
            self::$_validations[$cls][$attr] = array();
        }

        array_push(self::$_validations[$cls][$attr], $validation);
    }
168797
public function max($attr)
    {
        $builder = $this->_makeBuilderForAggregations(" max($attr) ");
        return $this->_executeAndReturnFirst($builder, $this->_vals);
    }
257577
public function set_session($attr){
    if ( $this->session->has(self::$un) ){
      $args = \func_get_args();
      if ( (\count($args) === 2) && \is_string($args[0]) ){
        $attr = [$args[0] => $args[1]];
      }
      foreach ( $attr as $key => $val ){
        if ( \is_string($key) ){
          $this->session->set($val, self::$un, $key);
        }
      }
    }
    return $this;
  }