SAN DIEGO -- A call came to the bullpen after the seventh inning, alerting Ian Kennedy that he might be dropped into the game a little early if Archie Bradley fell into an eighth-inning jam.

“So I got ready,” Kennedy said.

But it was hard to prepare for the situation Kennedy entered into: bases loaded, two outs, a two-run lead, MVP candidate Fernando Tatis Jr. standing at the plate, Manny Machado waiting on-deck, little room for error, and a ballpark ready to explode.

“You can bring him into some easier situations, I guess,” manager Joe Girardi said.

But nights like Friday -- when Kennedy recorded the final four outs of a needed 4-3 win over San Diego -- are why the Phillies traded for the right-hander last month before the deadline, believing Kennedy was the late-inning arm their bullpen needed. So far, he’s looked the part.

He finished a win the Phillies needed after they were swept this week in Arizona by the woeful Diamondbacks. The Phillies did not gain any ground on first-place Atlanta, who won earlier in the night in Baltimore.

But they did not drop any deeper in the standings after falling four games back this week. That was important.

“We all felt it,” said Kennedy, who combined with Bradley and Hector Neris for 14 outs. “Both teams are struggling. We’re all trying to compete for the playoffs. Someone has to win so it might as well be us. That was a big win.”

Kennedy hit Tatis in the helmet with a 2-2 fastball to bring home a run, cutting the Phils’ lead to one before he struck out Machado to leave the bases loaded. It was Kennedy’s fourth save with the Phillies, providing more evidence that he can handle the pressure that comes with the final outs.

“You probably couldn’t draw up a tougher situation,” starting pitcher Matt Moore said. “I can’t say enough about how big that was by Ian.”

A former starting pitcher, Kennedy moved to the bullpen two years ago with Kansas City, but this is his first chance at closing for a playoff contender. It was an opportunity Kennedy said he was looking forward to when he joined the Phillies.

Nearly a month later, that opportunity has met his expectations.

“This is what we play for, this is why I play,” Kennedy said. “Moments like tonight. You’re like a little kid in the backyard facing one of the best hitters in the game. It’s everything you dream of doing and you have all that adrenaline but you put yourself mentally in these situations so you don’t get too excited or too down, you just stay even keeled.

Last week, he was bitten by two close calls that went against him yet still earned a save against the Dodgers. Friday, he was on the right side of a close call as he shut the door on Machado.

“It’s nice to have a call go my way,” Kennedy said of the fastball that was called strike two. “I don’t know if that was off the plate, but it was nice to get a call go my way.”

Machado was quickly ejected after he struck out swinging as he hollered at home-plate umpire Doug Eddings. He then retreated near the on-deck circle, ripped off his batting gloves, and threw them 25 feet toward Eddings. Kennedy simply dropped his head and walked back to the dugout. Finally, the Phillies were not the ones left frustrated.

Harper’s non-solo blast

Bryce Harper showed what can happen when he has chances with runners on base when he smoked a two-run homer in the third inning. J.T. Realmuto doubled in a run and Harper followed with a homer to right that left the bat at 110 mph.

It was Harper’s 23rd homer of the season, but just his third with someone on base. Harper entered Friday with just 83 chances with runners in scoring position. With the way Harper is producing, it’s paramount that the Phillies find ways to get runners on base ahead of him.

Insurance run

Andrew McCutchen’s RBI double in the eighth inning allowed the bullpen to take a deep breath, but became even more important when Kennedy allowed a run to score in the bottom of the inning. It was just the team’s second hit since Harper’s third-inning homer as the offense went into a shell before McCutchen came through. The Phillies finished with just five hits, but they scored four runs. And all four scored with two outs. That worked.

“That’s the difference in the game,” Girardi said of McCutchen’s hit. “I thought he had good swings all night and that was a big one.”

Moore than enough

Moore didn’t flirt Friday night with a no-hitter but he did keep the Phillies in the game and that’s all you can ask for from the fifth starter. Moore allowed two runs on three hits before being lifted with one out in the fifth.

He allowed hard contact -- Machado’s two-run homer in the third left the bat at 119.6 mph -- and walked four batters yet kept the Phils afloat. He loaded the bases in the second before striking out Padres starter Blake Snell to end the rally. His 75th pitch was flied out to deep center field by Tatis, which was enough for Girardi to make a change as Machado came up again. It was the right move and Moore did his job.

“These team has been going good all year and we know their lineup can be a hassle at times,” Moore said. “What was on my mind, was to get as many outs as I can and not get too far ahead of myself.”

Waiting for Hoskins

Rhys Hoskins’ groin was still too sore for him to play Friday night, a week after he received a cortisone injection. Hoskins took batting practice on Friday afternoon and fielded ground balls but remained on the injured list. Girardi said there’s a chance that Hoskins could return on Saturday.

Odubel Herrera was out of Friday’s lineup after being hit in the elbow on Thursday by a pitch. Girard said Herrera was “pretty sore.” Herrera was replaced in center field by Jorge Bonifacio, who was promoted from triple A in the afternoon. Bonifacio, who played parts of the last four seasons in the majors with Kansas City and Detroit, went 0-for-3 and became the eighth Phillies player to start a game this season in center.