ObjectCalisthenics\Helper\PropertyFilter::getTrackedClassPropertyList PHP 메소드

getTrackedClassPropertyList() 공개 정적인 메소드

public static getTrackedClassPropertyList ( array $propertyList, array $trackedPropertyTypeList ) : array
$propertyList array
$trackedPropertyTypeList array
리턴 array
    public static function getTrackedClassPropertyList(array $propertyList, array $trackedPropertyTypeList) : array
    {
        return array_filter($propertyList, function ($property) use($trackedPropertyTypeList) {
            return in_array($property['type'], $trackedPropertyTypeList);
        });
    }

Usage Example

 private function checkTrackedClassPropertyAmount() : string
 {
     $trackedPropertyList = PropertyFilter::getTrackedClassPropertyList($this->propertyList, $this->getTrackedPropertyTypeList());
     $trackedPropertyAmount = count($trackedPropertyList);
     if ($trackedPropertyAmount > $this->trackedMaxCount) {
         $message = 'You have %d properties declared of "%s" type(s), must be less or equals than %d properties in total';
         $error = sprintf($message, $trackedPropertyAmount, implode('", "', $this->getTrackedPropertyTypeList()), $this->trackedMaxCount);
         return $error;
     }
     return '';
 }