protected function checkFieldNames($reference, $fieldNames)
    {
        $validFieldNames   = $this->getPublicFieldNames();
        $invalidFieldNames = [];
        foreach ($fieldNames as $fieldName) {
            if (!in_array($fieldName, $validFieldNames)) {
                $invalidFieldNames[] = $fieldName;
            }
        }
        if (!empty($invalidFieldNames)) {
            throw new \InvalidArgumentException('Invalid fields ('.join(', ', $invalidFieldNames).') in '.$reference.', valid ones are: '.join(', ', $validFieldNames));
        }
    }