Formulas/Resources/Formulas/Formula.php
private function hashArray( $elements )
	{
		$hashes = array();

		if ( is_array( $elements ) )
		{
			foreach ( $elements as $key => $element )
			{
				if ( is_object( $element ) )
				{
					$hash = spl_object_hash( $element ) . $key;
					$hashes[ $hash ] = $element;
				}
				else if ( is_array( $element ) )
				{
					extract( $this->hashArray( $element ) ) . $key;
					$hashes[ $hash ] = $element;
				}
				else
				{
					$hash = hash( 'sha256', $element . $key );
					$hashes[ $hash ] = $element;
				}
			}
		}
		else
		{
			$hash = hash( 'sha256', $elements );
			$hashes[ $hash ] = $elements;
		}

		return array( 'hash' => hash( 'sha256', serialize( array_keys( $hashes ) ) ), 'element_hashes' => $hashes );
	}
private function hashArray( $elements )
	{
		$hashes = array();

		if ( is_array( $elements ) )
		{
			foreach ( $elements as $key => $element )
			{
				if ( is_object( $element ) )
				{
					$hash = spl_object_hash( $element ) . $key;
					$hashes[ $hash ] = $element;
				}
				else if ( is_array( $element ) )
				{
					extract( $this->hashArray( $element ) ) . $key;
					$hashes[ $hash ] = $element;
				}
				else
				{
					$hash = hash( 'sha256', $element . $key );
					$hashes[ $hash ] = $element;
				}
			}
		}
		else
		{
			$hash = hash( 'sha256', $elements );
			$hashes[ $hash ] = $elements;
		}

		return array( 'hash' => hash( 'sha256', serialize( array_keys( $hashes ) ) ), 'element_hashes' => $hashes );
	}
private function hashArray ( $ elements ) { $ hashes = array ( ) ; if ( is_array ( $ elements ) ) { foreach ( $ elements as $ key => $ element ) { if ( is_object ( $ element ) ) { $ hash = spl_object_hash ( $ element ) . $ key ; $ hashes [ $ hash ] = $ element ; } else if ( is_array ( $ element ) ) { extract ( $ this -> hashArray ( $ element ) ) . $ key ; $ hashes [ $ hash ] = $ element ; } else { $ hash = hash ( 'sha256' , $ element . $ key ) ; $ hashes [ $ hash ] = $ element ; } } } else { $ hash = hash ( 'sha256' , $ elements ) ; $ hashes [ $ hash ] = $ elements ; } return array ( 'hash' => hash ( 'sha256' , serialize ( array_keys ( $ hashes ) ) ) , 'element_hashes' => $ hashes ) ; }
Generates hashes for all the elements of the key
@param $elements An array of key elements for which to create the hashes
@return array An array of the elements indexed by their hashes and the overall hash
Generates hashes for all the elements of the key