score:7
If you travel Portugal - Germany - Egypt, you will stay in the Schengen area till you leave Germany, you will have an internal Schengen area flight and get out of the Schengen area when you leave Germany.
If your layover is long enough you can leave the airport. For most European airports they advise not to leave the airport if your stop is less than 5 hours, but it does differ between the different airports.
On the other hand, if you fly from Portugal to Egypt and then to Germany, you would have left the Schengen area when leaving Portugal and would not be allowed into Germany, as your visit would be a second entry into the Schengen area.