for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace GolfLeague\Services;
use GolfLeague\Storage\Match\MatchRepository;
use GolfLeague\Storage\HoleScore\HoleScoreRepository as HoleScoreRepo;
use \Player;
use \Match;
use Illuminate\Events\Dispatcher;
/**
* ScoreService, containing all useful methods for business logic for scoring a round
*/
class ScoreService
{
// Containing our matchRepository to make all our database calls
protected $matchRepo;
* Loads our $matchRepo
*
* @param MatchRepository $matchRepo
* @return MatchService
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
public function __construct(MatchRepository $matchRepo,
HoleScoreRepo $holeScoreRepo,
Player $player,
Match $match,
Dispatcher $events)
$this->matchRepo = $matchRepo;
$this->holeScoreRepo = $holeScoreRepo;
holeScoreRepo
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->player = $player;
player
$this->match = $match;
match
$this->events = $events;
events
}
public function update($id, $score)
$this->holeScoreRepo->update($id, $score);
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.