src/Model/Device.php
public function identifyModel($pattern, $subject, $defaults = [])
    {
        if (preg_match($pattern, $subject, $match)) {
            $this->manufacturer = !empty($defaults['manufacturer']) ? $defaults['manufacturer'] : null;
            $this->model = Data\DeviceModels::cleanup($match[1]);
            $this->identifier = preg_replace('/ (Mozilla|Opera|Obigo|AU.Browser|UP.Browser|Build|Java|PPC|AU-MIC.*)$/iu', '', $match[0]);
            $this->identifier = preg_replace('/_(TD|GPRS|LTE|BLEU|CMCC|CUCC)$/iu', '', $match[0]);

            if (isset($defaults['model'])) {
                if (is_callable($defaults['model'])) {
                    $this->model = call_user_func($defaults['model'], $this->model);
                } else {
                    $this->model = $defaults['model'];
                }
            }

            $this->generic = false;
            $this->identified |= Constants\Id::PATTERN;

            if (!empty($defaults['carrier'])) {
                $this->carrier = $defaults['carrier'];
            }

            if (!empty($defaults['type'])) {
                $this->type = $defaults['type'];
            }
        }
    }
public function identifyModel($pattern, $subject, $defaults = [])
    {
        if (preg_match($pattern, $subject, $match)) {
            $this->manufacturer = !empty($defaults['manufacturer']) ? $defaults['manufacturer'] : null;
            $this->model = Data\DeviceModels::cleanup($match[1]);
            $this->identifier = preg_replace('/ (Mozilla|Opera|Obigo|AU.Browser|UP.Browser|Build|Java|PPC|AU-MIC.*)$/iu', '', $match[0]);
            $this->identifier = preg_replace('/_(TD|GPRS|LTE|BLEU|CMCC|CUCC)$/iu', '', $match[0]);

            if (isset($defaults['model'])) {
                if (is_callable($defaults['model'])) {
                    $this->model = call_user_func($defaults['model'], $this->model);
                } else {
                    $this->model = $defaults['model'];
                }
            }

            $this->generic = false;
            $this->identified |= Constants\Id::PATTERN;

            if (!empty($defaults['carrier'])) {
                $this->carrier = $defaults['carrier'];
            }

            if (!empty($defaults['type'])) {
                $this->type = $defaults['type'];
            }
        }
    }
public function identifyModel ( $ pattern , $ subject , $ defaults = [ ] ) { if ( preg_match ( $ pattern , $ subject , $ match ) ) { $ this -> manufacturer = ! empty ( $ defaults [ 'manufacturer' ] ) ? $ defaults [ 'manufacturer' ] : null ; $ this -> model = Data \ DeviceModels :: cleanup ( $ match [ 1 ] ) ; $ this -> identifier = preg_replace ( '/ (Mozilla|Opera|Obigo|AU.Browser|UP.Browser|Build|Java|PPC|AU-MIC.*)$/iu' , '' , $ match [ 0 ] ) ; $ this -> identifier = preg_replace ( '/_(TD|GPRS|LTE|BLEU|CMCC|CUCC)$/iu' , '' , $ match [ 0 ] ) ; if ( isset ( $ defaults [ 'model' ] ) ) { if ( is_callable ( $ defaults [ 'model' ] ) ) { $ this -> model = call_user_func ( $ defaults [ 'model' ] , $ this -> model ) ; } else { $ this -> model = $ defaults [ 'model' ] ; } } $ this -> generic = false ; $ this -> identified |= Constants \ Id :: PATTERN ; if ( ! empty ( $ defaults [ 'carrier' ] ) ) { $ this -> carrier = $ defaults [ 'carrier' ] ; } if ( ! empty ( $ defaults [ 'type' ] ) ) { $ this -> type = $ defaults [ 'type' ] ; } } }
Identify the manufacturer and model based on a pattern

@param   string      $pattern   The regular expression that defines the group that matches the model
@param   string      $subject   The string the regular expression is matched with
@param   array|null  $defaults  An optional array of properties to set together

@return string
Identify the manufacturer and model based on a pattern