It is a transfer of the meaning on the basis of comparison. Herman Paul points out that metaphor can be based on different types of similarity:
a) similarity of shape, e.g. head (of a cabbage), bottleneck, teeth (of a saw, a comb);
b) similarity of position, e.g. foot (of a page, of a mountain), head (of a procession);
c) similarity of function, behaviour e.g. a whip (an official in the British Parliament whose duty is to see that members were present at the voting);
d) similarity of colour, e.g. orange, hazel, chestnut etc.
In some cases we have a complex similarity, e.g. the leg of a table has a similarity to a human leg in its shape, position and function.
Many metaphors are based on parts of a human body, e.g. an eye of a needle, arms and mouth of a river, head of an army.
A special type of metaphor is when Proper names become common nouns, e.g. philistine - a mercenary person, vandals - destructive people, a Don Juan - a lover of many women etc.