Scrum In PHP

Scrum PHP logo

When I first got excited about agile software development in general and Scrum in particular, I geekishly came up with a PHP class with the goal of creating a Scrum object with its methods and properties. It’s still is a work in progress, as it doesn’t consider any artifacts. I didn’t really document the code in terms of comments, as I just have been too lazy busy lately. I tried to make variables and method names as “speaking” as possible, though.

Let me know what you think about it and feel free to enhance it, document it or write child or parent classes! 🙂

<?php

class Scrum
{

	protected	$scrumTeam;

	function __construct()
	{
		$this->scrumTeam = array(
			'productOwner'	=>	new ProductOwner(),
			'scrumMaster'	=>	new ScrumMaster(),
			'devTeam'		=>	array(
				new SoftwareDeveloper(),
				new SoftwareDeveloper(),
				new SoftwareDeveloper(),
				new SoftwareDeveloper(),
				new SoftwareDeveloper(),
				new SoftwareDeveloper()
			)
		);
	}

	public function runProcess()
	{
		while(count($this->scrumTeam['productOwner']->productBacklog) > 0)
		{
			$this->backlogGrooming();
			$sprintBacklog	=	$this->sprintPlanningMeeting();
			$done			=	array();

			foreach( $this->scrumTeam['devTeam'] as $developer )
			{
				$done[] = $developer->develop( array_shift($sprintBacklog) );
			}

			if( $this->sprintReview( $done, $sprintBacklog ) )
			{
				unset( $this->scrumTeam['productOwner']->productBacklog[0] );
			}
			$this->sprintRetrospective();
		}
	}

	protected function backlogGrooming()
	{
		foreach( $this->scrumTeam['productOwner']->productBacklog as $productBacklogItem )
		{
			$this->planningPoker( $productBacklogItem );
		}
	}

	protected function sprintPlanningMeeting()
	{
		$sprintBacklog		=	array();
		$rawSprintBacklog	=	array_shift($this->scrumTeam['productOwner']->productBacklog);

		foreach($rawSprintBacklog as $rawSprintBacklogItem)
		{
			$sprintBacklog[] = $this->planningPoker( $rawSprintBacklogItem );
		}

		return $sprintBacklog;
	}

	protected function sprintReview( $doneSprintBacklog, $sprintBacklog )
	{
		$sprintGoalReached = true;

		foreach($doneSprintBacklog as $sprintBacklogItem)
		{
			if(! $sprintBacklogItem->done)
			{
				$sprintGoalReached = false;
				break;
			}
		}

		return $sprintGoalReached;
	}

	protected function sprintRetrospective()
	{
		foreach($this->scrumTeam as $role)
		{
			if(is_array($role))
			{
				foreach($role as $roleOwner)
				{
					$roleOwner->giveFeedback();
				}
			}
			$role->giveFeedback();
		}
	}

	protected function planningPoker( $backlogItem )
	{
		switch($backlogItem->getSize())
		{
			case 'high':
				$backlogItem->setStoryPoints( 40 );
				break;
			case 'medium':
				$backlogItem->setStoryPoints( 13 );
				break;
			case 'low':
				$backlogItem->setStoryPoints( 3 );
				break;
			default:
				throw new Exception('Size can\'t be estimated.');
		}
		return $backlogItem;
	}
}

$scrum = new Scrum;
$scrum->runProcess();

One response to “Scrum In PHP”

  1. Fabian says :

    Really nice piece of code!

    But where is the coffee card in the planning poker? Why not adding a count variable to check a maximum number of turns?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s