How to programmatically get the field cardinality
Thanks for the comments, I figured out a way to get the number(cardinality). Hope it helps someone. 

(array) $user_fields = \Drupal::service('entity_field.manager')-&gt;getFieldDefinitions('user', 'user');

foreach ($user_fields as $user_field_name =&gt; $user_field_definition) {
    (array) $cardinality = $user_field_definition-&gt;get('fieldStorage')-&gt;get('cardinality');
}